mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-14 10:34:31 +00:00
Update Settings, remove reports page
This commit is contained in:
parent
f2055b4dcd
commit
9cf962fff5
4 changed files with 180 additions and 233 deletions
|
@ -12,223 +12,216 @@ use Carbon\Carbon;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App\Http\Controllers\Settings\{
|
use App\Http\Controllers\Settings\{
|
||||||
ExportSettings,
|
ExportSettings,
|
||||||
LabsSettings,
|
LabsSettings,
|
||||||
HomeSettings,
|
HomeSettings,
|
||||||
PrivacySettings,
|
PrivacySettings,
|
||||||
RelationshipSettings,
|
RelationshipSettings,
|
||||||
SecuritySettings
|
SecuritySettings
|
||||||
};
|
};
|
||||||
use App\Jobs\DeletePipeline\DeleteAccountPipeline;
|
use App\Jobs\DeletePipeline\DeleteAccountPipeline;
|
||||||
|
|
||||||
class SettingsController extends Controller
|
class SettingsController extends Controller
|
||||||
{
|
{
|
||||||
use ExportSettings,
|
use ExportSettings,
|
||||||
LabsSettings,
|
LabsSettings,
|
||||||
HomeSettings,
|
HomeSettings,
|
||||||
PrivacySettings,
|
PrivacySettings,
|
||||||
RelationshipSettings,
|
RelationshipSettings,
|
||||||
SecuritySettings;
|
SecuritySettings;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function accessibility()
|
public function accessibility()
|
||||||
{
|
{
|
||||||
$settings = Auth::user()->settings;
|
$settings = Auth::user()->settings;
|
||||||
|
|
||||||
return view('settings.accessibility', compact('settings'));
|
return view('settings.accessibility', compact('settings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function accessibilityStore(Request $request)
|
public function accessibilityStore(Request $request)
|
||||||
{
|
{
|
||||||
$settings = Auth::user()->settings;
|
$settings = Auth::user()->settings;
|
||||||
$fields = [
|
$fields = [
|
||||||
'compose_media_descriptions',
|
'compose_media_descriptions',
|
||||||
'reduce_motion',
|
'reduce_motion',
|
||||||
'optimize_screen_reader',
|
'optimize_screen_reader',
|
||||||
'high_contrast_mode',
|
'high_contrast_mode',
|
||||||
'video_autoplay',
|
'video_autoplay',
|
||||||
];
|
];
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$form = $request->input($field);
|
$form = $request->input($field);
|
||||||
if ($form == 'on') {
|
if ($form == 'on') {
|
||||||
$settings->{$field} = true;
|
$settings->{$field} = true;
|
||||||
} else {
|
} else {
|
||||||
$settings->{$field} = false;
|
$settings->{$field} = false;
|
||||||
}
|
}
|
||||||
$settings->save();
|
$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()
|
public function notifications()
|
||||||
{
|
{
|
||||||
return view('settings.notifications');
|
return view('settings.notifications');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function applications()
|
public function applications()
|
||||||
{
|
{
|
||||||
return view('settings.applications');
|
return view('settings.applications');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataImport()
|
public function dataImport()
|
||||||
{
|
{
|
||||||
abort_if(!config('pixelfed.import.instagram.enabled'), 404);
|
abort_if(!config('pixelfed.import.instagram.enabled'), 404);
|
||||||
return view('settings.import.home');
|
return view('settings.import.home');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function dataImportInstagram()
|
public function dataImportInstagram()
|
||||||
{
|
{
|
||||||
abort_if(!config('pixelfed.import.instagram.enabled'), 404);
|
abort_if(!config('pixelfed.import.instagram.enabled'), 404);
|
||||||
return view('settings.import.instagram.home');
|
return view('settings.import.instagram.home');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function developers()
|
public function developers()
|
||||||
{
|
{
|
||||||
return view('settings.developers');
|
return view('settings.developers');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeAccountTemporary(Request $request)
|
public function removeAccountTemporary(Request $request)
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
abort_if(!config('pixelfed.account_deletion'), 403);
|
abort_if(!config('pixelfed.account_deletion'), 403);
|
||||||
abort_if($user->is_admin, 403);
|
abort_if($user->is_admin, 403);
|
||||||
|
|
||||||
return view('settings.remove.temporary');
|
return view('settings.remove.temporary');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeAccountTemporarySubmit(Request $request)
|
public function removeAccountTemporarySubmit(Request $request)
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
abort_if(!config('pixelfed.account_deletion'), 403);
|
abort_if(!config('pixelfed.account_deletion'), 403);
|
||||||
abort_if($user->is_admin, 403);
|
abort_if($user->is_admin, 403);
|
||||||
$profile = $user->profile;
|
$profile = $user->profile;
|
||||||
$user->status = 'disabled';
|
$user->status = 'disabled';
|
||||||
$profile->status = 'disabled';
|
$profile->status = 'disabled';
|
||||||
$user->save();
|
$user->save();
|
||||||
$profile->save();
|
$profile->save();
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
Cache::forget('profiles:private');
|
Cache::forget('profiles:private');
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeAccountPermanent(Request $request)
|
public function removeAccountPermanent(Request $request)
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
abort_if($user->is_admin, 403);
|
abort_if($user->is_admin, 403);
|
||||||
return view('settings.remove.permanent');
|
return view('settings.remove.permanent');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function removeAccountPermanentSubmit(Request $request)
|
public function removeAccountPermanentSubmit(Request $request)
|
||||||
{
|
{
|
||||||
if(config('pixelfed.account_deletion') == false) {
|
if(config('pixelfed.account_deletion') == false) {
|
||||||
abort(404);
|
abort(404);
|
||||||
}
|
}
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
abort_if(!config('pixelfed.account_deletion'), 403);
|
abort_if(!config('pixelfed.account_deletion'), 403);
|
||||||
abort_if($user->is_admin, 403);
|
abort_if($user->is_admin, 403);
|
||||||
$profile = $user->profile;
|
$profile = $user->profile;
|
||||||
$ts = Carbon::now()->addMonth();
|
$ts = Carbon::now()->addMonth();
|
||||||
$user->status = 'delete';
|
$user->status = 'delete';
|
||||||
$profile->status = 'delete';
|
$profile->status = 'delete';
|
||||||
$user->delete_after = $ts;
|
$user->delete_after = $ts;
|
||||||
$profile->delete_after = $ts;
|
$profile->delete_after = $ts;
|
||||||
$user->save();
|
$user->save();
|
||||||
$profile->save();
|
$profile->save();
|
||||||
Cache::forget('profiles:private');
|
Cache::forget('profiles:private');
|
||||||
Auth::logout();
|
Auth::logout();
|
||||||
DeleteAccountPipeline::dispatch($user)->onQueue('high');
|
DeleteAccountPipeline::dispatch($user)->onQueue('high');
|
||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function requestFullExport(Request $request)
|
public function requestFullExport(Request $request)
|
||||||
{
|
{
|
||||||
$user = Auth::user();
|
$user = Auth::user();
|
||||||
return view('settings.export.show');
|
return view('settings.export.show');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function reportsHome(Request $request)
|
public function metroDarkMode(Request $request)
|
||||||
{
|
{
|
||||||
$profile = Auth::user()->profile;
|
$this->validate($request, [
|
||||||
$reports = Report::whereProfileId($profile->id)->orderByDesc('created_at')->paginate(10);
|
'mode' => 'required|string|in:light,dark'
|
||||||
return view('settings.reports', compact('reports'));
|
]);
|
||||||
}
|
|
||||||
|
|
||||||
public function metroDarkMode(Request $request)
|
$mode = $request->input('mode');
|
||||||
{
|
|
||||||
$this->validate($request, [
|
|
||||||
'mode' => 'required|string|in:light,dark'
|
|
||||||
]);
|
|
||||||
|
|
||||||
$mode = $request->input('mode');
|
if($mode == 'dark') {
|
||||||
|
$cookie = Cookie::make('dark-mode', true, 43800);
|
||||||
|
} else {
|
||||||
|
$cookie = Cookie::forget('dark-mode');
|
||||||
|
}
|
||||||
|
|
||||||
if($mode == 'dark') {
|
return response()->json([200])->cookie($cookie);
|
||||||
$cookie = Cookie::make('dark-mode', true, 43800);
|
}
|
||||||
} else {
|
|
||||||
$cookie = Cookie::forget('dark-mode');
|
|
||||||
}
|
|
||||||
|
|
||||||
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()
|
public function sponsorStore(Request $request)
|
||||||
{
|
{
|
||||||
$default = [
|
$this->validate($request, [
|
||||||
'patreon' => null,
|
'patreon' => 'nullable|string',
|
||||||
'liberapay' => null,
|
'liberapay' => 'nullable|string',
|
||||||
'opencollective' => null
|
'opencollective' => 'nullable|string'
|
||||||
];
|
]);
|
||||||
$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)
|
$patreon = Str::startsWith($request->input('patreon'), 'https://') ?
|
||||||
{
|
substr($request->input('patreon'), 8) :
|
||||||
$this->validate($request, [
|
$request->input('patreon');
|
||||||
'patreon' => 'nullable|string',
|
|
||||||
'liberapay' => 'nullable|string',
|
|
||||||
'opencollective' => 'nullable|string'
|
|
||||||
]);
|
|
||||||
|
|
||||||
$patreon = Str::startsWith($request->input('patreon'), 'https://') ?
|
$liberapay = Str::startsWith($request->input('liberapay'), 'https://') ?
|
||||||
substr($request->input('patreon'), 8) :
|
substr($request->input('liberapay'), 8) :
|
||||||
$request->input('patreon');
|
$request->input('liberapay');
|
||||||
|
|
||||||
$liberapay = Str::startsWith($request->input('liberapay'), 'https://') ?
|
$opencollective = Str::startsWith($request->input('opencollective'), 'https://') ?
|
||||||
substr($request->input('liberapay'), 8) :
|
substr($request->input('opencollective'), 8) :
|
||||||
$request->input('liberapay');
|
$request->input('opencollective');
|
||||||
|
|
||||||
$opencollective = Str::startsWith($request->input('opencollective'), 'https://') ?
|
$patreon = Str::startsWith($patreon, 'patreon.com/') ? e($patreon) : null;
|
||||||
substr($request->input('opencollective'), 8) :
|
$liberapay = Str::startsWith($liberapay, 'liberapay.com/') ? e($liberapay) : null;
|
||||||
$request->input('opencollective');
|
$opencollective = Str::startsWith($opencollective, 'opencollective.com/') ? e($opencollective) : null;
|
||||||
|
|
||||||
$patreon = Str::startsWith($patreon, 'patreon.com/') ? e($patreon) : null;
|
if(empty($patreon) && empty($liberapay) && empty($opencollective)) {
|
||||||
$liberapay = Str::startsWith($liberapay, 'liberapay.com/') ? e($liberapay) : null;
|
return redirect(route('settings'))->with('error', 'An error occured. Please try again later.');;
|
||||||
$opencollective = Str::startsWith($opencollective, 'opencollective.com/') ? e($opencollective) : null;
|
}
|
||||||
|
|
||||||
if(empty($patreon) && empty($liberapay) && empty($opencollective)) {
|
$res = [
|
||||||
return redirect(route('settings'))->with('error', 'An error occured. Please try again later.');;
|
'patreon' => $patreon,
|
||||||
}
|
'liberapay' => $liberapay,
|
||||||
|
'opencollective' => $opencollective
|
||||||
|
];
|
||||||
|
|
||||||
$res = [
|
$sponsors = ProfileSponsor::firstOrCreate([
|
||||||
'patreon' => $patreon,
|
'profile_id' => Auth::user()->profile_id ?? Auth::user()->profile->id
|
||||||
'liberapay' => $liberapay,
|
]);
|
||||||
'opencollective' => $opencollective
|
$sponsors->sponsors = json_encode($res);
|
||||||
];
|
$sponsors->save();
|
||||||
|
$sponsors = $res;
|
||||||
$sponsors = ProfileSponsor::firstOrCreate([
|
return redirect(route('settings'))->with('status', 'Sponsor settings successfully updated!');;
|
||||||
'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!');;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,16 +26,9 @@
|
||||||
<li class="nav-item pl-3 {{request()->is('settings/relationships*')?'active':''}}">
|
<li class="nav-item pl-3 {{request()->is('settings/relationships*')?'active':''}}">
|
||||||
<a class="nav-link font-weight-light text-muted" href="{{route('settings.relationships')}}">Relationships</a>
|
<a class="nav-link font-weight-light text-muted" href="{{route('settings.relationships')}}">Relationships</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item pl-3 {{request()->is('settings/reports*')?'active':''}}">
|
|
||||||
<a class="nav-link font-weight-light text-muted" href="{{route('settings.reports')}}">Reports</a>
|
|
||||||
</li>
|
|
||||||
|
|
||||||
<li class="nav-item pl-3 {{request()->is('settings/security*')?'active':''}}">
|
<li class="nav-item pl-3 {{request()->is('settings/security*')?'active':''}}">
|
||||||
<a class="nav-link font-weight-light text-muted" href="{{route('settings.security')}}">Security</a>
|
<a class="nav-link font-weight-light text-muted" href="{{route('settings.security')}}">Security</a>
|
||||||
</li>
|
</li>
|
||||||
{{-- <li class="nav-item pl-3 {{request()->is('settings/sponsor*')?'active':''}}">
|
|
||||||
<a class="nav-link font-weight-light text-muted" href="{{route('settings.sponsor')}}">Sponsor</a>
|
|
||||||
</li> --}}
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<hr>
|
<hr>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,38 +0,0 @@
|
||||||
@extends('settings.template')
|
|
||||||
|
|
||||||
@section('section')
|
|
||||||
|
|
||||||
<div class="title">
|
|
||||||
<h3 class="font-weight-bold">Reports</h3>
|
|
||||||
</div>
|
|
||||||
<hr>
|
|
||||||
<p class="lead">A list of reports you have made. </p>
|
|
||||||
<table class="table table-responsive">
|
|
||||||
<thead class="bg-light">
|
|
||||||
<th scope="col">ID</th>
|
|
||||||
<th scope="col">Type</th>
|
|
||||||
<th scope="col">Reported</th>
|
|
||||||
<th scope="col">Status</th>
|
|
||||||
<th scope="col">Created</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach($reports as $report)
|
|
||||||
<tr>
|
|
||||||
<td class="font-weight-bold">{{$report->id}}</td>
|
|
||||||
<td class="font-weight-bold">{{$report->type}}</td>
|
|
||||||
<td class="font-weight-bold"><a href="{{$report->reported()->url()}}">{{str_limit($report->reported()->url(), 30)}}</a></td>
|
|
||||||
@if(!$report->admin_seen)
|
|
||||||
<td><span class="text-danger font-weight-bold">Unresolved</span></td>
|
|
||||||
@else
|
|
||||||
<td><span class="text-success font-weight-bold">Resolved</span></td>
|
|
||||||
@endif
|
|
||||||
<td class="font-weight-bold">{{$report->created_at->diffForHumans(null, true, true)}}</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<div class="d-flex justify-content-center mt-5 small">
|
|
||||||
{{$reports->links()}}
|
|
||||||
</div>
|
|
||||||
@endsection
|
|
|
@ -351,7 +351,6 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
||||||
Route::post('privacy/blocked-instances/unblock', 'SettingsController@blockedInstanceUnblock')->name('settings.privacy.blocked-instances.unblock');
|
Route::post('privacy/blocked-instances/unblock', 'SettingsController@blockedInstanceUnblock')->name('settings.privacy.blocked-instances.unblock');
|
||||||
Route::get('privacy/blocked-keywords', 'SettingsController@blockedKeywords')->name('settings.privacy.blocked-keywords');
|
Route::get('privacy/blocked-keywords', 'SettingsController@blockedKeywords')->name('settings.privacy.blocked-keywords');
|
||||||
Route::post('privacy/account', 'SettingsController@privateAccountOptions')->name('settings.privacy.account');
|
Route::post('privacy/account', 'SettingsController@privateAccountOptions')->name('settings.privacy.account');
|
||||||
Route::get('reports', 'SettingsController@reportsHome')->name('settings.reports');
|
|
||||||
Route::group(['prefix' => 'remove', 'middleware' => 'dangerzone'], function() {
|
Route::group(['prefix' => 'remove', 'middleware' => 'dangerzone'], function() {
|
||||||
Route::get('request/temporary', 'SettingsController@removeAccountTemporary')->name('settings.remove.temporary');
|
Route::get('request/temporary', 'SettingsController@removeAccountTemporary')->name('settings.remove.temporary');
|
||||||
Route::post('request/temporary', 'SettingsController@removeAccountTemporarySubmit');
|
Route::post('request/temporary', 'SettingsController@removeAccountTemporarySubmit');
|
||||||
|
|
Loading…
Reference in a new issue