adds already sent exception in update message
This commit is contained in:
parent
0b1b7646d5
commit
feac25f401
3 changed files with 10 additions and 0 deletions
|
@ -785,5 +785,10 @@ return [
|
||||||
'name' => Exception::MESSAGE_NOT_FOUND,
|
'name' => Exception::MESSAGE_NOT_FOUND,
|
||||||
'description' => 'Message with the requested ID could not be found.',
|
'description' => 'Message with the requested ID could not be found.',
|
||||||
'code' => 404,
|
'code' => 404,
|
||||||
|
],
|
||||||
|
Exception::MESSAGE_ALREADY_SENT => [
|
||||||
|
'name' => Exception::MESSAGE_ALREADY_SENT,
|
||||||
|
'description' => 'Message with the requested ID has already been sent.',
|
||||||
|
'code' => 400,
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
|
|
@ -1703,6 +1703,10 @@ App::patch('/v1/messaging/messages/email/:messageId')
|
||||||
throw new Exception(Exception::MESSAGE_NOT_FOUND);
|
throw new Exception(Exception::MESSAGE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($message->getAttribute('status') === 'sent') {
|
||||||
|
throw new Exception(Exception::MESSAGE_ALREADY_SENT);
|
||||||
|
}
|
||||||
|
|
||||||
if (\count($to) > 0) {
|
if (\count($to) > 0) {
|
||||||
$message->setAttribute('to', $to);
|
$message->setAttribute('to', $to);
|
||||||
}
|
}
|
||||||
|
|
|
@ -240,6 +240,7 @@ class Exception extends \Exception
|
||||||
|
|
||||||
/** Message */
|
/** Message */
|
||||||
public const MESSAGE_NOT_FOUND = 'message_not_found';
|
public const MESSAGE_NOT_FOUND = 'message_not_found';
|
||||||
|
public const MESSAGE_ALREADY_SENT = 'message_already_sent';
|
||||||
|
|
||||||
protected $type = '';
|
protected $type = '';
|
||||||
protected $errors = [];
|
protected $errors = [];
|
||||||
|
|
Loading…
Reference in a new issue