Bläddra i källkod

Update AppRegister controller, add scheduled cleanup task to delete older than 90d

Daniel Supernault 1 månad sedan
förälder
incheckning
c319dfbcc4

+ 31 - 0
app/Console/Commands/CleanupExpiredAppRegistrations.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\AppRegister;
+use Illuminate\Console\Command;
+
+class CleanupExpiredAppRegistrations extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'app:cleanup-expired-app-registrations';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Command description';
+
+    /**
+     * Execute the console command.
+     */
+    public function handle()
+    {
+        AppRegister::where('created_at', '<', now()->subDays(90))->delete();
+    }
+}

+ 1 - 0
app/Console/Kernel.php

@@ -32,6 +32,7 @@ class Kernel extends ConsoleKernel
         $schedule->command('gc:passwordreset')->dailyAt('09:41')->onOneServer();
         $schedule->command('gc:sessions')->twiceDaily(13, 23)->onOneServer();
         $schedule->command('app:weekly-instance-scan')->weeklyOn(2, '4:20')->onOneServer();
+        $schedule->command('app:cleanup-expired-app-registrations')->dailyAt(1)->onOneServer();
 
         if ((bool) config_cache('pixelfed.cloud_storage') && (bool) config_cache('media.delete_local_after_cloud')) {
             $schedule->command('media:s3gc')->hourlyAt(15);

+ 2 - 2
app/Http/Controllers/AppRegisterController.php

@@ -111,7 +111,7 @@ class AppRegisterController extends Controller
 
         $exists = AppRegister::whereEmail($email)
             ->whereVerifyCode($code)
-            ->where('created_at', '>', now()->subDays(220))
+            ->where('created_at', '>', now()->subDays(90))
             ->exists();
 
         return response()->json([
@@ -219,7 +219,7 @@ class AppRegisterController extends Controller
 
         $exists = AppRegister::whereEmail($email)
             ->whereVerifyCode($code)
-            ->where('created_at', '>', now()->subDays(220))
+            ->where('created_at', '>', now()->subDays(90))
             ->exists();
 
         if (! $exists) {