mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-30 08:20:46 +00:00
Update AdminController, add appeals support
This commit is contained in:
parent
16c43ed0c4
commit
c95085ca31
1 changed files with 62 additions and 0 deletions
|
@ -3,6 +3,7 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use App\{
|
||||
AccountInterstitial,
|
||||
Contact,
|
||||
Hashtag,
|
||||
Newsroom,
|
||||
|
@ -85,6 +86,67 @@ class AdminController extends Controller
|
|||
return view('admin.reports.show', compact('report'));
|
||||
}
|
||||
|
||||
public function appeals(Request $request)
|
||||
{
|
||||
$appeals = AccountInterstitial::whereNotNull('appeal_requested_at')
|
||||
->whereNull('appeal_handled_at')
|
||||
->latest()
|
||||
->paginate(6);
|
||||
return view('admin.reports.appeals', compact('appeals'));
|
||||
}
|
||||
|
||||
public function showAppeal(Request $request, $id)
|
||||
{
|
||||
$appeal = AccountInterstitial::whereNotNull('appeal_requested_at')
|
||||
->whereNull('appeal_handled_at')
|
||||
->findOrFail($id);
|
||||
$meta = json_decode($appeal->meta);
|
||||
return view('admin.reports.show_appeal', compact('appeal', 'meta'));
|
||||
}
|
||||
|
||||
public function updateAppeal(Request $request, $id)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'action' => 'required|in:dismiss,approve'
|
||||
]);
|
||||
|
||||
$action = $request->input('action');
|
||||
$appeal = AccountInterstitial::whereNotNull('appeal_requested_at')
|
||||
->whereNull('appeal_handled_at')
|
||||
->findOrFail($id);
|
||||
|
||||
if($action == 'dismiss') {
|
||||
$appeal->appeal_handled_at = now();
|
||||
$appeal->save();
|
||||
|
||||
return redirect('/i/admin/reports/appeals');
|
||||
}
|
||||
|
||||
switch ($appeal->type) {
|
||||
case 'post.cw':
|
||||
$status = $appeal->status;
|
||||
$status->is_nsfw = false;
|
||||
$status->save();
|
||||
break;
|
||||
|
||||
case 'post.unlist':
|
||||
$status = $appeal->status;
|
||||
$status->scope = 'public';
|
||||
$status->visibility = 'public';
|
||||
$status->save();
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
$appeal->appeal_handled_at = now();
|
||||
$appeal->save();
|
||||
|
||||
return redirect('/i/admin/reports/appeals');
|
||||
}
|
||||
|
||||
public function profiles(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
|
|
Loading…
Reference in a new issue