From aee1d4406289c92651e3af3396ba79b5d0c97373 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 17 Jan 2024 14:57:29 +1300 Subject: [PATCH] Set failed and delivery errors for failure cases --- src/Appwrite/Platform/Workers/Messaging.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Messaging.php b/src/Appwrite/Platform/Workers/Messaging.php index 3267a9034e..cf05b42d43 100644 --- a/src/Appwrite/Platform/Workers/Messaging.php +++ b/src/Appwrite/Platform/Workers/Messaging.php @@ -127,8 +127,12 @@ class Messaging extends Action } if (empty($recipients)) { - Console::error('No valid recipients found.'); - return; + $dbForProject->updateDocument('messages', $message->getId(), $message->setAttributes([ + 'status' => 'failed', + 'deliveryErrors' => ['No valid recipients found.'] + ])); + + throw new \Exception('No valid recipients found.'); } $fallback = $dbForProject->findOne('providers', [ @@ -137,8 +141,12 @@ class Messaging extends Action ]); if ($fallback === false || $fallback->isEmpty()) { - Console::error('No fallback provider found.'); - return; + $dbForProject->updateDocument('messages', $message->getId(), $message->setAttributes([ + 'status' => 'failed', + 'deliveryErrors' => ['No fallback provider found.'] + ])); + + throw new \Exception('No fallback provider found.'); } /**