Update AdminReportController

This commit is contained in:
Daniel Supernault 2024-10-15 00:16:41 -06:00
parent 03ad41e2c4
commit 06ebb514d7
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1

View file

@ -3,18 +3,19 @@
namespace App\Http\Controllers\Admin;
use App\AccountInterstitial;
use App\Http\Resources\AdminReport;
use App\Http\Resources\AdminRemoteReport;
use App\Http\Resources\AdminReport;
use App\Http\Resources\AdminSpamReport;
use App\Jobs\DeletePipeline\DeleteAccountPipeline;
use App\Jobs\DeletePipeline\DeleteRemoteProfilePipeline;
use App\Jobs\StatusPipeline\RemoteStatusDelete;
use App\Jobs\StatusPipeline\StatusDelete;
use App\Jobs\StoryPipeline\StoryDelete;
use App\Models\ModeratedProfile;
use App\Models\RemoteReport;
use App\Notification;
use App\Profile;
use App\Report;
use App\Models\RemoteReport;
use App\Services\AccountService;
use App\Services\ModLogService;
use App\Services\NetworkTimelineService;
@ -25,11 +26,11 @@ use App\Status;
use App\Story;
use App\User;
use Cache;
use Storage;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use Storage;
trait AdminReportController
{
@ -201,10 +202,7 @@ trait AdminReportController
return 0;
}
public function render()
{
}
public function render() {}
};
}
@ -829,6 +827,16 @@ trait AdminReportController
$profile->cw = true;
$profile->save();
if ($profile->remote_url) {
ModeratedProfile::updateOrCreate([
'profile_url' => $profile->remote_url,
'profile_id' => $profile->id,
], [
'is_nsfw' => true,
'domain' => $profile->domain,
]);
}
foreach (Status::whereProfileId($profile->id)->cursor() as $status) {
$status->is_nsfw = true;
$status->save();
@ -879,6 +887,16 @@ trait AdminReportController
$profile->unlisted = true;
$profile->save();
if ($profile->remote_url) {
ModeratedProfile::updateOrCreate([
'profile_url' => $profile->remote_url,
'profile_id' => $profile->id,
], [
'is_unlisted' => true,
'domain' => $profile->domain,
]);
}
foreach (Status::whereProfileId($profile->id)->whereScope('public')->cursor() as $status) {
$status->scope = 'unlisted';
$status->visibility = 'unlisted';
@ -929,6 +947,16 @@ trait AdminReportController
$profile->unlisted = true;
$profile->save();
if ($profile->remote_url) {
ModeratedProfile::updateOrCreate([
'profile_url' => $profile->remote_url,
'profile_id' => $profile->id,
], [
'is_unlisted' => true,
'domain' => $profile->domain,
]);
}
foreach (Status::whereProfileId($profile->id)->cursor() as $status) {
$status->scope = 'private';
$status->visibility = 'private';
@ -982,6 +1010,16 @@ trait AdminReportController
$ts = now()->addMonth();
if ($profile->remote_url) {
ModeratedProfile::updateOrCreate([
'profile_url' => $profile->remote_url,
'profile_id' => $profile->id,
], [
'is_banned' => true,
'domain' => $profile->domain,
]);
}
if ($profile->user_id) {
$user = $profile->user;
abort_if($user->is_admin, 403, 'You cannot delete admin accounts.');
@ -1354,7 +1392,7 @@ trait AdminReportController
{
$this->validate($request, [
'id' => 'required|exists:remote_reports,id',
'action' => 'required|in:mark-read,cw-posts,unlist-posts,delete-posts,private-posts,mark-all-read-by-domain,mark-all-read-by-username,cw-all-posts,private-all-posts,unlist-all-posts'
'action' => 'required|in:mark-read,cw-posts,unlist-posts,delete-posts,private-posts,mark-all-read-by-domain,mark-all-read-by-username,cw-all-posts,private-all-posts,unlist-all-posts',
]);
$report = RemoteReport::findOrFail($request->input('id'));
@ -1504,7 +1542,7 @@ trait AdminReportController
->action('admin.report.moderate')
->metadata([
'action' => $request->input('action'),
'duration_active' => now()->parse($report->created_at)->diffForHumans()
'duration_active' => now()->parse($report->created_at)->diffForHumans(),
])
->accessLevel('admin')
->save();
@ -1516,6 +1554,7 @@ trait AdminReportController
->update(['action_taken_at' => now()]);
}
}
return [200];
}
}