From ce78d8c473f0116f0dbe3e593641ff1394df048f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 15 Jan 2024 19:29:19 +1300 Subject: [PATCH] Set schedule inactive after message send so deletes worker picks it up --- src/Appwrite/Platform/Tasks/ScheduleBase.php | 1 + src/Appwrite/Platform/Tasks/ScheduleMessages.php | 8 ++++++++ src/Appwrite/Platform/Workers/Messaging.php | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/ScheduleBase.php b/src/Appwrite/Platform/Tasks/ScheduleBase.php index ed42a45e4e..1ec8e471bb 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleBase.php +++ b/src/Appwrite/Platform/Tasks/ScheduleBase.php @@ -70,6 +70,7 @@ abstract class ScheduleBase extends Action ); return [ + '$id' => $schedule->getId(), 'resourceId' => $schedule->getAttribute('resourceId'), 'schedule' => $schedule->getAttribute('schedule'), 'resourceUpdatedAt' => $schedule->getAttribute('resourceUpdatedAt'), diff --git a/src/Appwrite/Platform/Tasks/ScheduleMessages.php b/src/Appwrite/Platform/Tasks/ScheduleMessages.php index 9ede91279d..ee11578fea 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleMessages.php +++ b/src/Appwrite/Platform/Tasks/ScheduleMessages.php @@ -50,6 +50,14 @@ class ScheduleMessages extends ScheduleBase ->setProject($schedule['project']) ->trigger(); + $dbForConsole->updateDocument( + 'schedules', + $schedule['$id'], + $dbForConsole + ->getDocument('schedules', $schedule['$id']) + ->setAttribute('active', false) + ); + $queueForDeletes ->setType(DELETE_TYPE_SCHEDULES) ->setDocument($schedule) diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index d57e1837d7..9b7bda57bb 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -134,7 +134,7 @@ class Messaging extends Action Query::equal('type', [$recipients[0]->getAttribute('providerType')]), ]); - if ($fallback === false) { + if ($fallback === false || $fallback->isEmpty()) { Console::error('No fallback provider found.'); return; }