Update inactive users deletion handling

This commit is contained in:
DariusIII
2025-05-14 10:00:04 +02:00
parent 42119b57d7
commit 3c742ce310
3 changed files with 13 additions and 2 deletions
+1
View File
@@ -195,6 +195,7 @@ HORIZON_PREFIX=horizon:
POSTMARK_TOKEN=
PURGE_INACTIVE_USERS=false
PURGE_INACTIVE_USERS_DAYS=180
OTP_ENABLED=false
+11 -2
View File
@@ -28,7 +28,16 @@ class RemoveInactiveAccounts implements ShouldQueue
*/
public function handle(): void
{
User::query()->where('lastlogin', '<', now()->subMonths(6))->where('apiaccess', '<', now()->subMonths(6))->where('roles_id', '=', 1)->delete();
User::query()->where('lastlogin', '<', now()->subMonths(6))->whereNull('apiaccess')->where('roles_id', '=', 1)->delete();
$purgeDays = config('nntmux.purge_inactive_users_days');
User::query()->where('roles_id', '=', 1)
->where(function ($query) use ($purgeDays) {
$query->where('lastlogin', '<', now()->subDays($purgeDays))
->orWhereNull('lastlogin');
})
->where(function ($query) use ($purgeDays) {
$query->where('apiaccess', '<', now()->subDays($purgeDays))
->orWhereNull('apiaccess');
})
->delete();
}
}
+1
View File
@@ -16,6 +16,7 @@ return [
'admin_email' => env('ADMIN_EMAIL', 'admin@example.com'),
'multiprocessing_max_child_time' => env('NN_MULTIPROCESSING_MAX_CHILD_TIME', 1800),
'purge_inactive_users' => env('PURGE_INACTIVE_USERS', false),
'purge_inactive_users_days' => env('PURGE_INACTIVE_USERS_DAYS', 180),
'elasticsearch_enabled' => env('ELASTICSEARCH_ENABLED', false),
'btcpay_webhook_secret' => env('BTCPAY_SECRET'),
'tmp_unrar_path' => env('TEMP_UNRAR_PATH', storage_path('tmp/unrar/')),