mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update AdminController
This commit is contained in:
parent
9cd4bd74a5
commit
6d078377f1
2 changed files with 60 additions and 5 deletions
|
@ -139,6 +139,9 @@ class AdminController extends Controller
|
|||
$appeal->appeal_handled_at = now();
|
||||
$appeal->save();
|
||||
|
||||
Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $status->profile_id);
|
||||
Cache::forget('pf:bouncer_v0:recent_by_pid:' . $status->profile_id);
|
||||
|
||||
return redirect('/i/admin/reports/autospam');
|
||||
}
|
||||
|
||||
|
@ -151,6 +154,9 @@ class AdminController extends Controller
|
|||
$appeal->appeal_handled_at = now();
|
||||
$appeal->save();
|
||||
|
||||
Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $status->profile_id);
|
||||
Cache::forget('pf:bouncer_v0:recent_by_pid:' . $status->profile_id);
|
||||
|
||||
return redirect('/i/admin/reports/autospam');
|
||||
}
|
||||
|
||||
|
|
|
@ -15,12 +15,50 @@ class Bouncer {
|
|||
return;
|
||||
}
|
||||
|
||||
$recentKey = 'pf:bouncer:recent_by_pid:' . $status->profile_id;
|
||||
$recentTtl = now()->addMinutes(5);
|
||||
$recent = Cache::remember($recentKey, $recentTtl, function() use($status) {
|
||||
return $status->profile->created_at->gt(now()->subMonths(2)) || $status->profile->statuses()->count() == 0;
|
||||
$exemptionKey = 'pf:bouncer_v0:exemption_by_pid:' . $status->profile_id;
|
||||
$exemptionTtl = now()->addDays(12);
|
||||
|
||||
$exemption = Cache::remember($exemptionKey, $exemptionTtl, function() use($status) {
|
||||
$uid = $status->profile->user_id;
|
||||
$ids = AccountInterstitial::whereUserId($uid)
|
||||
->whereType('post.autospam')
|
||||
->whereItemType('App\Status')
|
||||
->whereNotNull('appeal_handled_at')
|
||||
->latest()
|
||||
->take(5)
|
||||
->pluck('item_id');
|
||||
|
||||
if($ids->count() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$count = Status::select('id', 'scope')
|
||||
->whereScope('public')
|
||||
->find($ids)
|
||||
->count();
|
||||
|
||||
return $count >= 1 ? true : false;
|
||||
});
|
||||
|
||||
if($exemption == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
$recentKey = 'pf:bouncer_v0:recent_by_pid:' . $status->profile_id;
|
||||
$recentTtl = now()->addHours(28);
|
||||
|
||||
$recent = Cache::remember($recentKey, $recentTtl, function() use($status) {
|
||||
return $status
|
||||
->profile
|
||||
->created_at
|
||||
->gt(now()->subMonths(6)) ||
|
||||
$status
|
||||
->profile
|
||||
->statuses()
|
||||
->whereScope('public')
|
||||
->count() == 0;
|
||||
});
|
||||
|
||||
if(!$recent) {
|
||||
return;
|
||||
}
|
||||
|
@ -29,7 +67,16 @@ class Bouncer {
|
|||
return;
|
||||
}
|
||||
|
||||
if(!Str::contains($status->caption, ['https://', 'http://', 'hxxps://', 'hxxp://', 'www.', '.com', '.net', '.org'])) {
|
||||
if(!Str::contains($status->caption, [
|
||||
'https://',
|
||||
'http://',
|
||||
'hxxps://',
|
||||
'hxxp://',
|
||||
'www.',
|
||||
'.com',
|
||||
'.net',
|
||||
'.org'
|
||||
])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -74,6 +121,8 @@ class Bouncer {
|
|||
$status->is_nsfw = true;
|
||||
$status->save();
|
||||
|
||||
Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $status->profile_id);
|
||||
Cache::forget('pf:bouncer_v0:recent_by_pid:' . $status->profile_id);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue