From afb32b49d517a85d58887c1d0b7e72ea5beffab1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 30 Jan 2024 16:33:18 +1300 Subject: [PATCH] Throw if status still scheduled and scheduled time before now --- app/controllers/api/messaging.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index b2970f3d0a..895fba08b1 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -3297,6 +3297,14 @@ App::delete('/v1/messaging/messages/:messageId') throw new Exception(Exception::MESSAGE_ALREADY_SCHEDULED); case MessageStatus::SCHEDULED: $scheduleId = $message->getAttribute('scheduleId'); + $scheduledAt = $message->getAttribute('scheduledAt'); + + $now = DateTime::now(); + $scheduledDate = DateTime::formatTz($scheduledAt); + + if ($now > $scheduledDate) { + throw new Exception(Exception::MESSAGE_ALREADY_SCHEDULED); + } if (!empty($scheduleId)) { try {