From 1eddcb50bf220642a9575cf216166808dca33c42 Mon Sep 17 00:00:00 2001 From: Clemente Raposo Date: Mon, 20 Feb 2023 18:44:21 +0000 Subject: [PATCH] [Legacy] Update AlertSchedulers alert reminder time calculation Update calculation to on create the notification with the time that as scheduled for --- .../services/AddScheduledReminderAlerts.php | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/public/legacy/modules/Alerts/services/AddScheduledReminderAlerts.php b/public/legacy/modules/Alerts/services/AddScheduledReminderAlerts.php index 6cf0ef889..23d3832b9 100644 --- a/public/legacy/modules/Alerts/services/AddScheduledReminderAlerts.php +++ b/public/legacy/modules/Alerts/services/AddScheduledReminderAlerts.php @@ -89,7 +89,9 @@ class AddScheduledReminderAlerts continue; } - if ($this->isOutsideOfExecutionDateRange($relatedEventStart, $dateTimeNowStamp, $dateTimeMaxStamp)) { + $relatedEventStart -= $popupReminder->timer_popup; + + if (!$this->isWithinExecutionDateRange($relatedEventStart, $dateTimeNowStamp, $dateTimeMaxStamp)) { continue; } @@ -104,8 +106,6 @@ class AddScheduledReminderAlerts continue; } - $relatedEventStart -= $popupReminder->timer_popup; - $url = $this->getURL($popupReminder); $instructions = $this->getInstructions($app_strings['MSG_JS_ALERT_MTG_REMINDER_MEETING_MSG']); @@ -302,10 +302,22 @@ class AddScheduledReminderAlerts * @param $dateTimeMaxStamp * @return bool */ - protected function isOutsideOfExecutionDateRange($relatedEventStart, $dateTimeNowStamp, $dateTimeMaxStamp): bool + protected function isWithinExecutionDateRange($relatedEventStart, $dateTimeNowStamp, $dateTimeMaxStamp): bool { - return $relatedEventStart - && ($relatedEventStart <= $dateTimeNowStamp || $relatedEventStart >= $dateTimeMaxStamp); + if (empty($relatedEventStart)) { + return false; + } + + //increase time by 10 secs to make sure we calculate within the correct minute + if (($dateTimeNowStamp + 10) < $relatedEventStart) { + return false; + } + + if ($relatedEventStart > $dateTimeMaxStamp) { + return false; + } + + return true; } /**