diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index 7b59132fe..92cddec4a 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -12,223 +12,216 @@ use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Str; use App\Http\Controllers\Settings\{ - ExportSettings, - LabsSettings, - HomeSettings, - PrivacySettings, - RelationshipSettings, - SecuritySettings + ExportSettings, + LabsSettings, + HomeSettings, + PrivacySettings, + RelationshipSettings, + SecuritySettings }; use App\Jobs\DeletePipeline\DeleteAccountPipeline; class SettingsController extends Controller { - use ExportSettings, - LabsSettings, - HomeSettings, - PrivacySettings, - RelationshipSettings, - SecuritySettings; + use ExportSettings, + LabsSettings, + HomeSettings, + PrivacySettings, + RelationshipSettings, + SecuritySettings; - public function __construct() - { - $this->middleware('auth'); - } + public function __construct() + { + $this->middleware('auth'); + } - public function accessibility() - { - $settings = Auth::user()->settings; + public function accessibility() + { + $settings = Auth::user()->settings; - return view('settings.accessibility', compact('settings')); - } + return view('settings.accessibility', compact('settings')); + } - public function accessibilityStore(Request $request) - { - $settings = Auth::user()->settings; - $fields = [ - 'compose_media_descriptions', - 'reduce_motion', - 'optimize_screen_reader', - 'high_contrast_mode', - 'video_autoplay', - ]; - foreach ($fields as $field) { - $form = $request->input($field); - if ($form == 'on') { - $settings->{$field} = true; - } else { - $settings->{$field} = false; - } - $settings->save(); - } + public function accessibilityStore(Request $request) + { + $settings = Auth::user()->settings; + $fields = [ + 'compose_media_descriptions', + 'reduce_motion', + 'optimize_screen_reader', + 'high_contrast_mode', + 'video_autoplay', + ]; + foreach ($fields as $field) { + $form = $request->input($field); + if ($form == 'on') { + $settings->{$field} = true; + } else { + $settings->{$field} = false; + } + $settings->save(); + } - return redirect(route('settings.accessibility'))->with('status', 'Settings successfully updated!'); - } + return redirect(route('settings.accessibility'))->with('status', 'Settings successfully updated!'); + } - public function notifications() - { - return view('settings.notifications'); - } + public function notifications() + { + return view('settings.notifications'); + } - public function applications() - { - return view('settings.applications'); - } + public function applications() + { + return view('settings.applications'); + } - public function dataImport() - { - abort_if(!config('pixelfed.import.instagram.enabled'), 404); - return view('settings.import.home'); - } + public function dataImport() + { + abort_if(!config('pixelfed.import.instagram.enabled'), 404); + return view('settings.import.home'); + } - public function dataImportInstagram() - { - abort_if(!config('pixelfed.import.instagram.enabled'), 404); - return view('settings.import.instagram.home'); - } + public function dataImportInstagram() + { + abort_if(!config('pixelfed.import.instagram.enabled'), 404); + return view('settings.import.instagram.home'); + } - public function developers() - { - return view('settings.developers'); - } + public function developers() + { + return view('settings.developers'); + } - public function removeAccountTemporary(Request $request) - { - $user = Auth::user(); - abort_if(!config('pixelfed.account_deletion'), 403); - abort_if($user->is_admin, 403); + public function removeAccountTemporary(Request $request) + { + $user = Auth::user(); + abort_if(!config('pixelfed.account_deletion'), 403); + abort_if($user->is_admin, 403); - return view('settings.remove.temporary'); - } + return view('settings.remove.temporary'); + } - public function removeAccountTemporarySubmit(Request $request) - { - $user = Auth::user(); - abort_if(!config('pixelfed.account_deletion'), 403); - abort_if($user->is_admin, 403); - $profile = $user->profile; - $user->status = 'disabled'; - $profile->status = 'disabled'; - $user->save(); - $profile->save(); - Auth::logout(); - Cache::forget('profiles:private'); - return redirect('/'); - } + public function removeAccountTemporarySubmit(Request $request) + { + $user = Auth::user(); + abort_if(!config('pixelfed.account_deletion'), 403); + abort_if($user->is_admin, 403); + $profile = $user->profile; + $user->status = 'disabled'; + $profile->status = 'disabled'; + $user->save(); + $profile->save(); + Auth::logout(); + Cache::forget('profiles:private'); + return redirect('/'); + } - public function removeAccountPermanent(Request $request) - { - $user = Auth::user(); - abort_if($user->is_admin, 403); - return view('settings.remove.permanent'); - } + public function removeAccountPermanent(Request $request) + { + $user = Auth::user(); + abort_if($user->is_admin, 403); + return view('settings.remove.permanent'); + } - public function removeAccountPermanentSubmit(Request $request) - { - if(config('pixelfed.account_deletion') == false) { - abort(404); - } - $user = Auth::user(); - abort_if(!config('pixelfed.account_deletion'), 403); - abort_if($user->is_admin, 403); - $profile = $user->profile; - $ts = Carbon::now()->addMonth(); - $user->status = 'delete'; - $profile->status = 'delete'; - $user->delete_after = $ts; - $profile->delete_after = $ts; - $user->save(); - $profile->save(); - Cache::forget('profiles:private'); - Auth::logout(); - DeleteAccountPipeline::dispatch($user)->onQueue('high'); - return redirect('/'); - } + public function removeAccountPermanentSubmit(Request $request) + { + if(config('pixelfed.account_deletion') == false) { + abort(404); + } + $user = Auth::user(); + abort_if(!config('pixelfed.account_deletion'), 403); + abort_if($user->is_admin, 403); + $profile = $user->profile; + $ts = Carbon::now()->addMonth(); + $user->status = 'delete'; + $profile->status = 'delete'; + $user->delete_after = $ts; + $profile->delete_after = $ts; + $user->save(); + $profile->save(); + Cache::forget('profiles:private'); + Auth::logout(); + DeleteAccountPipeline::dispatch($user)->onQueue('high'); + return redirect('/'); + } - public function requestFullExport(Request $request) - { - $user = Auth::user(); - return view('settings.export.show'); - } + public function requestFullExport(Request $request) + { + $user = Auth::user(); + return view('settings.export.show'); + } - public function reportsHome(Request $request) - { - $profile = Auth::user()->profile; - $reports = Report::whereProfileId($profile->id)->orderByDesc('created_at')->paginate(10); - return view('settings.reports', compact('reports')); - } + public function metroDarkMode(Request $request) + { + $this->validate($request, [ + 'mode' => 'required|string|in:light,dark' + ]); - public function metroDarkMode(Request $request) - { - $this->validate($request, [ - 'mode' => 'required|string|in:light,dark' - ]); - - $mode = $request->input('mode'); + $mode = $request->input('mode'); - if($mode == 'dark') { - $cookie = Cookie::make('dark-mode', true, 43800); - } else { - $cookie = Cookie::forget('dark-mode'); - } + if($mode == 'dark') { + $cookie = Cookie::make('dark-mode', true, 43800); + } else { + $cookie = Cookie::forget('dark-mode'); + } - return response()->json([200])->cookie($cookie); - } + return response()->json([200])->cookie($cookie); + } - public function sponsor() - { - $default = [ - 'patreon' => null, - 'liberapay' => null, - 'opencollective' => null - ]; - $sponsors = ProfileSponsor::whereProfileId(Auth::user()->profile->id)->first(); - $sponsors = $sponsors ? json_decode($sponsors->sponsors, true) : $default; - return view('settings.sponsor', compact('sponsors')); - } + public function sponsor() + { + $default = [ + 'patreon' => null, + 'liberapay' => null, + 'opencollective' => null + ]; + $sponsors = ProfileSponsor::whereProfileId(Auth::user()->profile->id)->first(); + $sponsors = $sponsors ? json_decode($sponsors->sponsors, true) : $default; + return view('settings.sponsor', compact('sponsors')); + } - public function sponsorStore(Request $request) - { - $this->validate($request, [ - 'patreon' => 'nullable|string', - 'liberapay' => 'nullable|string', - 'opencollective' => 'nullable|string' - ]); + public function sponsorStore(Request $request) + { + $this->validate($request, [ + 'patreon' => 'nullable|string', + 'liberapay' => 'nullable|string', + 'opencollective' => 'nullable|string' + ]); - $patreon = Str::startsWith($request->input('patreon'), 'https://') ? - substr($request->input('patreon'), 8) : - $request->input('patreon'); + $patreon = Str::startsWith($request->input('patreon'), 'https://') ? + substr($request->input('patreon'), 8) : + $request->input('patreon'); - $liberapay = Str::startsWith($request->input('liberapay'), 'https://') ? - substr($request->input('liberapay'), 8) : - $request->input('liberapay'); - - $opencollective = Str::startsWith($request->input('opencollective'), 'https://') ? - substr($request->input('opencollective'), 8) : - $request->input('opencollective'); + $liberapay = Str::startsWith($request->input('liberapay'), 'https://') ? + substr($request->input('liberapay'), 8) : + $request->input('liberapay'); - $patreon = Str::startsWith($patreon, 'patreon.com/') ? e($patreon) : null; - $liberapay = Str::startsWith($liberapay, 'liberapay.com/') ? e($liberapay) : null; - $opencollective = Str::startsWith($opencollective, 'opencollective.com/') ? e($opencollective) : null; + $opencollective = Str::startsWith($request->input('opencollective'), 'https://') ? + substr($request->input('opencollective'), 8) : + $request->input('opencollective'); - if(empty($patreon) && empty($liberapay) && empty($opencollective)) { - return redirect(route('settings'))->with('error', 'An error occured. Please try again later.');; - } + $patreon = Str::startsWith($patreon, 'patreon.com/') ? e($patreon) : null; + $liberapay = Str::startsWith($liberapay, 'liberapay.com/') ? e($liberapay) : null; + $opencollective = Str::startsWith($opencollective, 'opencollective.com/') ? e($opencollective) : null; - $res = [ - 'patreon' => $patreon, - 'liberapay' => $liberapay, - 'opencollective' => $opencollective - ]; + if(empty($patreon) && empty($liberapay) && empty($opencollective)) { + return redirect(route('settings'))->with('error', 'An error occured. Please try again later.');; + } - $sponsors = ProfileSponsor::firstOrCreate([ - 'profile_id' => Auth::user()->profile_id ?? Auth::user()->profile->id - ]); - $sponsors->sponsors = json_encode($res); - $sponsors->save(); - $sponsors = $res; - return redirect(route('settings'))->with('status', 'Sponsor settings successfully updated!');; - } + $res = [ + 'patreon' => $patreon, + 'liberapay' => $liberapay, + 'opencollective' => $opencollective + ]; + + $sponsors = ProfileSponsor::firstOrCreate([ + 'profile_id' => Auth::user()->profile_id ?? Auth::user()->profile->id + ]); + $sponsors->sponsors = json_encode($res); + $sponsors->save(); + $sponsors = $res; + return redirect(route('settings'))->with('status', 'Sponsor settings successfully updated!');; + } } diff --git a/resources/views/settings/partial/sidebar.blade.php b/resources/views/settings/partial/sidebar.blade.php index 08f7ed304..478bc3a8b 100644 --- a/resources/views/settings/partial/sidebar.blade.php +++ b/resources/views/settings/partial/sidebar.blade.php @@ -16,7 +16,7 @@ @endif
A list of reports you have made.
-ID | -Type | -Reported | -Status | -Created | - - - - @foreach($reports as $report) -|
---|---|---|---|---|---|
{{$report->id}} | -{{$report->type}} | -{{str_limit($report->reported()->url(), 30)}} | - @if(!$report->admin_seen) -Unresolved | - @else -Resolved | - @endif -{{$report->created_at->diffForHumans(null, true, true)}} | -