Throw on updating sent, processing, failed message
This commit is contained in:
parent
560e458fa0
commit
f237e863de
3 changed files with 33 additions and 6 deletions
|
@ -867,6 +867,16 @@ return [
|
|||
'description' => 'Message with the requested ID has already been sent.',
|
||||
'code' => 400,
|
||||
],
|
||||
Exception::MESSAGE_ALREADY_PROCESSING => [
|
||||
'name' => Exception::MESSAGE_ALREADY_PROCESSING,
|
||||
'description' => 'Message with the requested ID is already being processed.',
|
||||
'code' => 400,
|
||||
],
|
||||
Exception::MESSAGE_ALREADY_FAILED => [
|
||||
'name' => Exception::MESSAGE_ALREADY_FAILED,
|
||||
'description' => 'Message with the requested ID has already failed.',
|
||||
'code' => 400,
|
||||
],
|
||||
Exception::MESSAGE_ALREADY_SCHEDULED => [
|
||||
'name' => Exception::MESSAGE_ALREADY_SCHEDULED,
|
||||
'description' => 'Message with the requested ID has already been scheduled for delivery.',
|
||||
|
|
|
@ -3077,8 +3077,13 @@ App::patch('/v1/messaging/messages/email/:messageId')
|
|||
throw new Exception(Exception::MESSAGE_NOT_FOUND);
|
||||
}
|
||||
|
||||
if ($message->getAttribute('status') === MessageStatus::SENT) {
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_SENT);
|
||||
switch ($message->getAttribute('status')) {
|
||||
case MessageStatus::PROCESSING:
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_PROCESSING);
|
||||
case MessageStatus::SENT:
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_SENT);
|
||||
case MessageStatus::FAILED:
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_FAILED);
|
||||
}
|
||||
|
||||
if (!\is_null($message->getAttribute('scheduledAt')) && $message->getAttribute('scheduledAt') < new \DateTime()) {
|
||||
|
@ -3207,8 +3212,13 @@ App::patch('/v1/messaging/messages/sms/:messageId')
|
|||
throw new Exception(Exception::MESSAGE_NOT_FOUND);
|
||||
}
|
||||
|
||||
if ($message->getAttribute('status') === 'sent') {
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_SENT);
|
||||
switch ($message->getAttribute('status')) {
|
||||
case MessageStatus::PROCESSING:
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_PROCESSING);
|
||||
case MessageStatus::SENT:
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_SENT);
|
||||
case MessageStatus::FAILED:
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_FAILED);
|
||||
}
|
||||
|
||||
if (!is_null($message->getAttribute('scheduledAt')) && $message->getAttribute('scheduledAt') < new \DateTime()) {
|
||||
|
@ -3329,8 +3339,13 @@ App::patch('/v1/messaging/messages/push/:messageId')
|
|||
throw new Exception(Exception::MESSAGE_NOT_FOUND);
|
||||
}
|
||||
|
||||
if ($message->getAttribute('status') === 'sent') {
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_SENT);
|
||||
switch ($message->getAttribute('status')) {
|
||||
case MessageStatus::PROCESSING:
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_PROCESSING);
|
||||
case MessageStatus::SENT:
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_SENT);
|
||||
case MessageStatus::FAILED:
|
||||
throw new Exception(Exception::MESSAGE_ALREADY_FAILED);
|
||||
}
|
||||
|
||||
if (!is_null($message->getAttribute('scheduledAt')) && $message->getAttribute('scheduledAt') < new \DateTime()) {
|
||||
|
|
|
@ -264,6 +264,8 @@ class Exception extends \Exception
|
|||
public const MESSAGE_NOT_FOUND = 'message_not_found';
|
||||
public const MESSAGE_MISSING_TARGET = 'message_missing_target';
|
||||
public const MESSAGE_ALREADY_SENT = 'message_already_sent';
|
||||
public const MESSAGE_ALREADY_PROCESSING = 'message_already_processing';
|
||||
public const MESSAGE_ALREADY_FAILED = 'message_already_failed';
|
||||
public const MESSAGE_ALREADY_SCHEDULED = 'message_already_scheduled';
|
||||
public const MESSAGE_TARGET_NOT_EMAIL = 'message_target_not_email';
|
||||
public const MESSAGE_TARGET_NOT_SMS = 'message_target_not_sms';
|
||||
|
|
Loading…
Reference in a new issue