Parcourir la source

Update admin autospam apis, remove autospam warning notifications when appropriate

Daniel Supernault il y a 2 ans
Parent
commit
588ca653a8

+ 17 - 0
app/Http/Controllers/Admin/AdminReportController.php

@@ -14,6 +14,7 @@ use App\{
 	Contact,
 	Contact,
 	Hashtag,
 	Hashtag,
 	Newsroom,
 	Newsroom,
+	Notification,
 	OauthClient,
 	OauthClient,
 	Profile,
 	Profile,
 	Report,
 	Report,
@@ -30,6 +31,7 @@ use App\Jobs\DeletePipeline\DeleteRemoteStatusPipeline;
 use App\Jobs\StatusPipeline\StatusDelete;
 use App\Jobs\StatusPipeline\StatusDelete;
 use App\Http\Resources\AdminReport;
 use App\Http\Resources\AdminReport;
 use App\Http\Resources\AdminSpamReport;
 use App\Http\Resources\AdminSpamReport;
+use App\Services\NotificationService;
 use App\Services\PublicTimelineService;
 use App\Services\PublicTimelineService;
 use App\Services\NetworkTimelineService;
 use App\Services\NetworkTimelineService;
 
 
@@ -1126,6 +1128,14 @@ trait AdminReportController
 			$appeal->appeal_handled_at = now();
 			$appeal->appeal_handled_at = now();
 			$appeal->save();
 			$appeal->save();
 
 
+			Notification::whereAction('autospam.warning')
+				->whereProfileId($appeal->user->profile_id)
+				->get()
+				->each(function($n) use($appeal) {
+					NotificationService::del($appeal->user->profile_id, $n->id);
+					$n->forceDelete();
+				});
+
 			StatusService::del($status->id);
 			StatusService::del($status->id);
 		}
 		}
 
 
@@ -1157,6 +1167,13 @@ trait AdminReportController
 						$status->save();
 						$status->save();
 						StatusService::del($status->id);
 						StatusService::del($status->id);
 					}
 					}
+					Notification::whereAction('autospam.warning')
+						->whereProfileId($report->user->profile_id)
+						->get()
+						->each(function($n) use($report) {
+							NotificationService::del($report->user->profile_id, $n->id);
+							$n->forceDelete();
+						});
 				});
 				});
 		}
 		}
 
 

+ 17 - 0
app/Http/Controllers/Api/AdminApiController.php

@@ -11,6 +11,7 @@ use App\{
     AccountInterstitial,
     AccountInterstitial,
     Instance,
     Instance,
     Like,
     Like,
+    Notification,
     Media,
     Media,
     Profile,
     Profile,
     Report,
     Report,
@@ -140,6 +141,14 @@ class AdminApiController extends Controller
 
 
             StatusService::del($status->id);
             StatusService::del($status->id);
 
 
+			Notification::whereAction('autospam.warning')
+				->whereProfileId($appeal->user->profile_id)
+				->get()
+				->each(function($n) use($appeal) {
+					NotificationService::del($appeal->user->profile_id, $n->id);
+					$n->forceDelete();
+				});
+
             Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $appeal->user->profile_id);
             Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $appeal->user->profile_id);
             Cache::forget('pf:bouncer_v0:recent_by_pid:' . $appeal->user->profile_id);
             Cache::forget('pf:bouncer_v0:recent_by_pid:' . $appeal->user->profile_id);
             Cache::forget('admin-dash:reports:spam-count');
             Cache::forget('admin-dash:reports:spam-count');
@@ -164,6 +173,14 @@ class AdminApiController extends Controller
                         $status->save();
                         $status->save();
                         StatusService::del($status->id, true);
                         StatusService::del($status->id, true);
                     }
                     }
+
+					Notification::whereAction('autospam.warning')
+						->whereProfileId($report->user->profile_id)
+						->get()
+						->each(function($n) use($report) {
+							NotificationService::del($report->user->profile_id, $n->id);
+							$n->forceDelete();
+						});
                 });
                 });
             Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $appeal->user->profile_id);
             Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $appeal->user->profile_id);
             Cache::forget('pf:bouncer_v0:recent_by_pid:' . $appeal->user->profile_id);
             Cache::forget('pf:bouncer_v0:recent_by_pid:' . $appeal->user->profile_id);