Throw if status scheduled and no schedule set
This commit is contained in:
parent
65573adad6
commit
d292562090
|
@ -4,6 +4,7 @@
|
||||||
* List of server wide error codes and their respective messages.
|
* List of server wide error codes and their respective messages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Appwrite\Enum\MessageStatus;
|
||||||
use Appwrite\Extend\Exception;
|
use Appwrite\Extend\Exception;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
@ -871,10 +872,14 @@ return [
|
||||||
'description' => 'Message with the target ID is not a push target.',
|
'description' => 'Message with the target ID is not a push target.',
|
||||||
'code' => 400,
|
'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 => [
|
Exception::SCHEDULE_NOT_FOUND => [
|
||||||
'name' => Exception::SCHEDULE_NOT_FOUND,
|
'name' => Exception::SCHEDULE_NOT_FOUND,
|
||||||
'description' => 'Schedule with the requested ID could not be found.',
|
'description' => 'Schedule with the requested ID could not be found.',
|
||||||
'code' => 404,
|
'code' => 404,
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
|
@ -2287,6 +2287,10 @@ App::post('/v1/messaging/messages/email')
|
||||||
throw new Exception(Exception::MESSAGE_MISSING_TARGET);
|
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);
|
$mergedTargets = \array_merge($targets, $cc, $bcc);
|
||||||
|
|
||||||
if (!empty($mergedTargets)) {
|
if (!empty($mergedTargets)) {
|
||||||
|
@ -2401,6 +2405,10 @@ App::post('/v1/messaging/messages/sms')
|
||||||
throw new Exception(Exception::MESSAGE_MISSING_TARGET);
|
throw new Exception(Exception::MESSAGE_MISSING_TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($status === MessageStatus::SCHEDULED && \is_null($scheduledAt)) {
|
||||||
|
throw new Exception(Exception::MESSAGE_MISSING_SCHEDULE);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($targets)) {
|
if (!empty($targets)) {
|
||||||
$foundTargets = $dbForProject->find('targets', [
|
$foundTargets = $dbForProject->find('targets', [
|
||||||
Query::equal('$id', $targets),
|
Query::equal('$id', $targets),
|
||||||
|
@ -2516,6 +2524,10 @@ App::post('/v1/messaging/messages/push')
|
||||||
throw new Exception(Exception::MESSAGE_MISSING_TARGET);
|
throw new Exception(Exception::MESSAGE_MISSING_TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($status === MessageStatus::SCHEDULED && \is_null($scheduledAt)) {
|
||||||
|
throw new Exception(Exception::MESSAGE_MISSING_SCHEDULE);
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($targets)) {
|
if (!empty($targets)) {
|
||||||
$foundTargets = $dbForProject->find('targets', [
|
$foundTargets = $dbForProject->find('targets', [
|
||||||
Query::equal('$id', $targets),
|
Query::equal('$id', $targets),
|
||||||
|
|
|
@ -262,6 +262,7 @@ class Exception extends \Exception
|
||||||
public const MESSAGE_TARGET_NOT_EMAIL = 'message_target_not_email';
|
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_SMS = 'message_target_not_sms';
|
||||||
public const MESSAGE_TARGET_NOT_PUSH = 'message_target_not_push';
|
public const MESSAGE_TARGET_NOT_PUSH = 'message_target_not_push';
|
||||||
|
public const MESSAGE_MISSING_SCHEDULE = 'message_missing_schedule';
|
||||||
|
|
||||||
/** Schedules */
|
/** Schedules */
|
||||||
public const SCHEDULE_NOT_FOUND = 'schedule_not_found';
|
public const SCHEDULE_NOT_FOUND = 'schedule_not_found';
|
||||||
|
|
Loading…
Reference in a new issue