From 7694c57e783ada21d127ebbaf5a43dcbbce5e911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Jaussoin?= Date: Sun, 11 May 2025 22:22:00 +0200 Subject: [PATCH] Cleanup Infos from the DB not updated after two months, they will be refresh if required --- src/Movim/Daemon/Core.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Movim/Daemon/Core.php b/src/Movim/Daemon/Core.php index bcc49219e..5c5ce4b32 100644 --- a/src/Movim/Daemon/Core.php +++ b/src/Movim/Daemon/Core.php @@ -17,6 +17,7 @@ use Movim\Daemon\Session; use App\Session as DBSession; use App\EncryptedPassword; use App\PushSubscription; +use App\Info; use Minishlink\WebPush\VAPID; class Core implements MessageComponentInterface @@ -218,11 +219,28 @@ class Core implements MessageComponentInterface } $this->cleanupDBSessions(); + }); + + $this->cleanupEncryptedPasswords(); + $this->cleanupPushSubscriptions(); + $this->cleanupInfos(); + + $this->loop->addPeriodicTimer(60 * 60 * 24, function () { $this->cleanupEncryptedPasswords(); $this->cleanupPushSubscriptions(); + $this->cleanupInfos(); }); } + /** + * @desc Delete infos that were pulled after two months, they will be refreshed if required + */ + private function cleanupInfos() + { + Info::where('updated_at', '<', date(MOVIM_SQL_DATE, time() - (60 * 60 * 24 * 30 * 2))) + ->delete(); + } + private function cleanupDBSessions() { DBSession::where('active', false)