mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 06:21:27 +00:00
Add AdminReportController
This commit is contained in:
parent
f969b40928
commit
707b686e8a
1 changed files with 85 additions and 0 deletions
85
app/Http/Controllers/Admin/AdminReportController.php
Normal file
85
app/Http/Controllers/Admin/AdminReportController.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Carbon\Carbon;
|
||||
use App\{Comment, Like, Media, Profile, Report, Status, User};
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
trait AdminReportController
|
||||
{
|
||||
public function updateReport(Request $request, $id)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'action' => 'required|string'
|
||||
]);
|
||||
|
||||
$action = $request->input('action');
|
||||
|
||||
$actions = [
|
||||
'ignore',
|
||||
'cw',
|
||||
'unlist',
|
||||
'delete',
|
||||
'shadowban',
|
||||
'ban'
|
||||
];
|
||||
|
||||
if(!in_array($action, $actions)) {
|
||||
return abort(403);
|
||||
}
|
||||
|
||||
$report = Report::findOrFail($id);
|
||||
|
||||
$this->handleReportAction($report, $action);
|
||||
|
||||
return response()->json(['msg'=> 'Success']);
|
||||
}
|
||||
|
||||
public function handleReportAction(Report $report, $action)
|
||||
{
|
||||
$item = $report->reported();
|
||||
$report->admin_seen = Carbon::now();
|
||||
|
||||
switch ($action) {
|
||||
case 'ignore':
|
||||
$report->not_interested = true;
|
||||
break;
|
||||
|
||||
case 'cw':
|
||||
$item->is_nsfw = true;
|
||||
$item->save();
|
||||
$report->nsfw = true;
|
||||
break;
|
||||
|
||||
case 'unlist':
|
||||
$item->visibility = 'unlisted';
|
||||
$item->save();
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
// Todo: fire delete job
|
||||
$report->admin_seen = null;
|
||||
break;
|
||||
|
||||
case 'shadowban':
|
||||
// Todo: fire delete job
|
||||
$report->admin_seen = null;
|
||||
break;
|
||||
|
||||
case 'ban':
|
||||
// Todo: fire delete job
|
||||
$report->admin_seen = null;
|
||||
break;
|
||||
|
||||
default:
|
||||
$report->admin_seen = null;
|
||||
break;
|
||||
}
|
||||
|
||||
$report->save();
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue