1
0
Fork 0
mirror of synced 2024-07-01 20:50:49 +12:00

Throw if status scheduled and no schedule set

This commit is contained in:
Jake Barnby 2024-01-19 16:16:24 +13:00
parent 65573adad6
commit d292562090
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
3 changed files with 19 additions and 1 deletions

View file

@ -4,6 +4,7 @@
* List of server wide error codes and their respective messages.
*/
use Appwrite\Enum\MessageStatus;
use Appwrite\Extend\Exception;
return [
@ -871,10 +872,14 @@ return [
'description' => 'Message with the target ID is not a push target.',
'code' => 400,
],
Exception::MESSAGE_MISSING_SCHEDULE => [
'name' => Exception::MESSAGE_MISSING_SCHEDULE,
'description' => 'Message can not have status ' . MessageStatus::SCHEDULED . ' without a schedule.',
'code' => 400,
],
Exception::SCHEDULE_NOT_FOUND => [
'name' => Exception::SCHEDULE_NOT_FOUND,
'description' => 'Schedule with the requested ID could not be found.',
'code' => 404,
],
];

View file

@ -2287,6 +2287,10 @@ App::post('/v1/messaging/messages/email')
throw new Exception(Exception::MESSAGE_MISSING_TARGET);
}
if ($status === MessageStatus::SCHEDULED && \is_null($scheduledAt)) {
throw new Exception(Exception::MESSAGE_MISSING_SCHEDULE);
}
$mergedTargets = \array_merge($targets, $cc, $bcc);
if (!empty($mergedTargets)) {
@ -2401,6 +2405,10 @@ App::post('/v1/messaging/messages/sms')
throw new Exception(Exception::MESSAGE_MISSING_TARGET);
}
if ($status === MessageStatus::SCHEDULED && \is_null($scheduledAt)) {
throw new Exception(Exception::MESSAGE_MISSING_SCHEDULE);
}
if (!empty($targets)) {
$foundTargets = $dbForProject->find('targets', [
Query::equal('$id', $targets),
@ -2516,6 +2524,10 @@ App::post('/v1/messaging/messages/push')
throw new Exception(Exception::MESSAGE_MISSING_TARGET);
}
if ($status === MessageStatus::SCHEDULED && \is_null($scheduledAt)) {
throw new Exception(Exception::MESSAGE_MISSING_SCHEDULE);
}
if (!empty($targets)) {
$foundTargets = $dbForProject->find('targets', [
Query::equal('$id', $targets),

View file

@ -262,6 +262,7 @@ class Exception extends \Exception
public const MESSAGE_TARGET_NOT_EMAIL = 'message_target_not_email';
public const MESSAGE_TARGET_NOT_SMS = 'message_target_not_sms';
public const MESSAGE_TARGET_NOT_PUSH = 'message_target_not_push';
public const MESSAGE_MISSING_SCHEDULE = 'message_missing_schedule';
/** Schedules */
public const SCHEDULE_NOT_FOUND = 'schedule_not_found';