From 707b686e8ad338a6a9371397886e4aa5579c33b3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 19 Aug 2018 16:35:16 -0600 Subject: [PATCH] Add AdminReportController --- .../Admin/AdminReportController.php | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 app/Http/Controllers/Admin/AdminReportController.php diff --git a/app/Http/Controllers/Admin/AdminReportController.php b/app/Http/Controllers/Admin/AdminReportController.php new file mode 100644 index 00000000..0e72e7ef --- /dev/null +++ b/app/Http/Controllers/Admin/AdminReportController.php @@ -0,0 +1,85 @@ +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; + } +} \ No newline at end of file