From 563817a94af86e646bee5c747282e98240bb630d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 18 Apr 2022 00:30:06 -0600 Subject: [PATCH 1/2] Update AdminReportController, add account delete button --- .../Admin/AdminReportController.php | 39 ++++++++++++++++++- .../views/admin/reports/show_spam.blade.php | 9 ++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Admin/AdminReportController.php b/app/Http/Controllers/Admin/AdminReportController.php index acfa17397..8b4c9d0d7 100644 --- a/app/Http/Controllers/Admin/AdminReportController.php +++ b/app/Http/Controllers/Admin/AdminReportController.php @@ -22,6 +22,8 @@ use App\{ }; use Illuminate\Validation\Rule; use App\Services\StoryService; +use App\Services\ModLogService; +use App\Jobs\DeletePipeline\DeleteAccountPipeline; trait AdminReportController { @@ -243,7 +245,7 @@ trait AdminReportController public function updateSpam(Request $request, $id) { $this->validate($request, [ - 'action' => 'required|in:dismiss,approve,dismiss-all,approve-all' + 'action' => 'required|in:dismiss,approve,dismiss-all,approve-all,delete-account' ]); $action = $request->input('action'); @@ -257,6 +259,41 @@ trait AdminReportController Cache::forget('admin-dash:reports:spam-count:total'); Cache::forget('admin-dash:reports:spam-count:30d'); + if($action == 'delete-account') { + if(config('pixelfed.account_deletion') == false) { + abort(404); + } + + $user = User::findOrFail($appeal->user_id); + $profile = $user->profile; + + if($user->is_admin == true) { + $mid = $request->user()->id; + abort_if($user->id < $mid, 403); + } + + $ts = now()->addMonth(); + $user->status = 'delete'; + $profile->status = 'delete'; + $user->delete_after = $ts; + $profile->delete_after = $ts; + $user->save(); + $profile->save(); + + ModLogService::boot() + ->objectUid($user->id) + ->objectId($user->id) + ->objectType('App\User::class') + ->user($request->user()) + ->action('admin.user.delete') + ->accessLevel('admin') + ->save(); + + Cache::forget('profiles:private'); + DeleteAccountPipeline::dispatch($user)->onQueue('high'); + return; + } + if($action == 'dismiss') { $appeal->is_spam = true; $appeal->appeal_handled_at = $now; diff --git a/resources/views/admin/reports/show_spam.blade.php b/resources/views/admin/reports/show_spam.blade.php index 970f881ea..c001b39a1 100644 --- a/resources/views/admin/reports/show_spam.blade.php +++ b/resources/views/admin/reports/show_spam.blade.php @@ -48,7 +48,8 @@
- + + @endif
@@ -105,6 +106,12 @@ return; } break; + + case 'delete-account': + if(!window.confirm('Are you sure you want to delete this account?')) { + return; + } + break; } axios.post(window.location.href, { From 2b188acff3fe0b938f0ab1d837dfe6447be9b1a2 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Mon, 18 Apr 2022 00:30:33 -0600 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 332fc6a30..06e31b9a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -124,6 +124,7 @@ - Updated ApiV1Controller, add missing pagination header. ([5649873a](https://github.com/pixelfed/pixelfed/commit/5649873a)) - Updated CollectionController, limit unpublished collections to owner. ([a0061eb5](https://github.com/pixelfed/pixelfed/commit/a0061eb5)) - Updated AP Inbox, fixes #3332. ([f8931dc7](https://github.com/pixelfed/pixelfed/commit/f8931dc7)) +- Updated AdminReportController, add account delete button. ([563817a9](https://github.com/pixelfed/pixelfed/commit/563817a9)) - ([](https://github.com/pixelfed/pixelfed/commit/)) ## [v0.11.2 (2022-01-09)](https://github.com/pixelfed/pixelfed/compare/v0.11.1...v0.11.2)