diff --git a/app/Domains/Contact/ManageReminders/Jobs/ProcessScheduledContactReminders.php b/app/Domains/Contact/ManageReminders/Jobs/ProcessScheduledContactReminders.php index b6a4ae488c4..b4c5e047faf 100644 --- a/app/Domains/Contact/ManageReminders/Jobs/ProcessScheduledContactReminders.php +++ b/app/Domains/Contact/ManageReminders/Jobs/ProcessScheduledContactReminders.php @@ -57,16 +57,20 @@ public function handle() $this->updateScheduledContactReminderTriggeredAt($scheduledReminder); $this->updateNumberOfTimesTriggered($scheduledReminder->contact_reminder_id); + + (new RescheduleContactReminderForChannel())->execute([ + 'contact_reminder_id' => $scheduledReminder->contact_reminder_id, + 'user_notification_channel_id' => $scheduledReminder->user_notification_channel_id, + 'contact_reminder_scheduled_id' => $scheduledReminder->id, + ]); } } private function updateScheduledContactReminderTriggeredAt($scheduledReminder): void { - (new RescheduleContactReminderForChannel())->execute([ - 'contact_reminder_id' => $scheduledReminder->contact_reminder_id, - 'user_notification_channel_id' => $scheduledReminder->user_notification_channel_id, - 'contact_reminder_scheduled_id' => $scheduledReminder->id, - ]); + DB::table('contact_reminder_scheduled') + ->where('id', $scheduledReminder->id) + ->update(['triggered_at' => Carbon::now()]); } private function updateNumberOfTimesTriggered(int $id): void diff --git a/app/Domains/Contact/ManageReminders/Services/RescheduleContactReminderForChannel.php b/app/Domains/Contact/ManageReminders/Services/RescheduleContactReminderForChannel.php index 1a27a52082f..feabaf2c809 100644 --- a/app/Domains/Contact/ManageReminders/Services/RescheduleContactReminderForChannel.php +++ b/app/Domains/Contact/ManageReminders/Services/RescheduleContactReminderForChannel.php @@ -57,6 +57,8 @@ public function execute(array $data): void if ($this->contactReminder->type !== ContactReminder::TYPE_ONE_TIME) { $this->schedule(); + } else { + $this->contactReminder->delete(); } }