1
0
Fork 0

Update AdminReportController, add account delete button

This commit is contained in:
Daniel Supernault 2022-04-18 00:30:06 -06:00
parent 4671836c26
commit 563817a94a
No known key found for this signature in database
GPG Key ID: 0DEF1C662C9033F7
2 changed files with 46 additions and 2 deletions

View File

@ -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;

View File

@ -48,7 +48,8 @@
<button type="button" class="btn btn-light border btn-block font-weight-bold mb-3 action-btn" data-action="approve">Mark as not spam</button>
<hr>
<button type="button" class="btn btn-default border btn-block font-weight-bold mb-3 action-btn" data-action="dismiss-all">Mark all as read</button>
<button type="button" class="btn btn-light border btn-block font-weight-bold mb-3 action-btn mb-5" data-action="approve-all">Mark all as not spam</button>
<button type="button" class="btn btn-light border btn-block font-weight-bold mb-3 action-btn" data-action="approve-all">Mark all as not spam</button>
<button type="button" class="btn btn-danger border btn-block font-weight-bold mb-3 action-btn mb-5" data-action="delete-account">Delete Account</button>
@endif
<div class="card shadow-none border">
<div class="card-header text-center font-weight-bold bg-light">
@ -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, {