diff --git a/app/Http/Controllers/Api/AdminApiController.php b/app/Http/Controllers/Api/AdminApiController.php new file mode 100644 index 000000000..dfacf47ee --- /dev/null +++ b/app/Http/Controllers/Api/AdminApiController.php @@ -0,0 +1,116 @@ +middleware(['auth', 'admin']); + } + + public function activity(Request $request) + { + $activity = []; + + $limit = request()->input('limit', 20); + + $activity['captions'] = Status::select( + 'id', + 'caption', + 'rendered', + 'uri', + 'profile_id', + 'type', + 'in_reply_to_id', + 'reblog_of_id', + 'is_nsfw', + 'scope', + 'created_at' + )->whereNull('in_reply_to_id') + ->whereNull('reblog_of_id') + ->orderByDesc('created_at') + ->paginate($limit); + + $activity['comments'] = Status::select( + 'id', + 'caption', + 'rendered', + 'uri', + 'profile_id', + 'type', + 'in_reply_to_id', + 'reblog_of_id', + 'is_nsfw', + 'scope', + 'created_at' + )->whereNotNull('in_reply_to_id') + ->whereNull('reblog_of_id') + ->orderByDesc('created_at') + ->paginate($limit); + + return response()->json($activity, 200, [], JSON_PRETTY_PRINT); + } + + public function moderateStatus(Request $request) + { + $this->validate($request, [ + 'type' => 'required|string|in:status,profile', + 'id' => 'required|integer|min:1', + 'action' => 'required|string|in:cw,unlink,unlist,suspend,delete' + ]); + + $type = $request->input('type'); + $id = $request->input('id'); + $action = $request->input('action'); + + if ($type == 'status') { + $status = Status::findOrFail($id); + switch ($action) { + case 'cw': + $status->is_nsfw = true; + $status->save(); + break; + case 'unlink': + $status->rendered = $status->caption; + $status->save(); + break; + case 'unlist': + $status->scope = 'unlisted'; + $status->visibility = 'unlisted'; + $status->save(); + break; + + default: + break; + } + } else if ($type == 'profile') { + $profile = Profile::findOrFail($id); + switch ($action) { + + case 'delete': + StatusDelete::dispatch($status); + break; + + default: + break; + } + } + + } + +} \ No newline at end of file