Set failed and delivery errors for failure cases

This commit is contained in:
Jake Barnby 2024-01-17 14:57:29 +13:00
parent 0ffe1d5346
commit aee1d44062
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C

View file

@ -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.');
}
/**