1
0
Fork 0
mirror of synced 2024-07-06 07:00:56 +12:00

adds already sent exception in update message

This commit is contained in:
Prateek Banga 2023-10-13 18:35:49 +05:30
parent 0b1b7646d5
commit feac25f401
3 changed files with 10 additions and 0 deletions

View file

@ -785,5 +785,10 @@ return [
'name' => Exception::MESSAGE_NOT_FOUND,
'description' => 'Message with the requested ID could not be found.',
'code' => 404,
],
Exception::MESSAGE_ALREADY_SENT => [
'name' => Exception::MESSAGE_ALREADY_SENT,
'description' => 'Message with the requested ID has already been sent.',
'code' => 400,
]
];

View file

@ -1703,6 +1703,10 @@ App::patch('/v1/messaging/messages/email/:messageId')
throw new Exception(Exception::MESSAGE_NOT_FOUND);
}
if ($message->getAttribute('status') === 'sent') {
throw new Exception(Exception::MESSAGE_ALREADY_SENT);
}
if (\count($to) > 0) {
$message->setAttribute('to', $to);
}

View file

@ -240,6 +240,7 @@ class Exception extends \Exception
/** Message */
public const MESSAGE_NOT_FOUND = 'message_not_found';
public const MESSAGE_ALREADY_SENT = 'message_already_sent';
protected $type = '';
protected $errors = [];