mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Update AdminReportController, add account delete button
This commit is contained in:
parent
4671836c26
commit
563817a94a
2 changed files with 46 additions and 2 deletions
|
@ -22,6 +22,8 @@ use App\{
|
||||||
};
|
};
|
||||||
use Illuminate\Validation\Rule;
|
use Illuminate\Validation\Rule;
|
||||||
use App\Services\StoryService;
|
use App\Services\StoryService;
|
||||||
|
use App\Services\ModLogService;
|
||||||
|
use App\Jobs\DeletePipeline\DeleteAccountPipeline;
|
||||||
|
|
||||||
trait AdminReportController
|
trait AdminReportController
|
||||||
{
|
{
|
||||||
|
@ -243,7 +245,7 @@ trait AdminReportController
|
||||||
public function updateSpam(Request $request, $id)
|
public function updateSpam(Request $request, $id)
|
||||||
{
|
{
|
||||||
$this->validate($request, [
|
$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');
|
$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:total');
|
||||||
Cache::forget('admin-dash:reports:spam-count:30d');
|
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') {
|
if($action == 'dismiss') {
|
||||||
$appeal->is_spam = true;
|
$appeal->is_spam = true;
|
||||||
$appeal->appeal_handled_at = $now;
|
$appeal->appeal_handled_at = $now;
|
||||||
|
|
|
@ -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>
|
<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>
|
<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-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
|
@endif
|
||||||
<div class="card shadow-none border">
|
<div class="card shadow-none border">
|
||||||
<div class="card-header text-center font-weight-bold bg-light">
|
<div class="card-header text-center font-weight-bold bg-light">
|
||||||
|
@ -105,6 +106,12 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'delete-account':
|
||||||
|
if(!window.confirm('Are you sure you want to delete this account?')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
axios.post(window.location.href, {
|
axios.post(window.location.href, {
|
||||||
|
|
Loading…
Reference in a new issue