Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix salesagility#10630 - Scheduled task “Run Email Reminder Notifications” does not run when deleting a person #10631

Open
wants to merge 1 commit into
base: hotfix
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions modules/Reminders/Reminder.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,19 @@ private static function getEmailReminderInviteesRecipients($reminderId, $checkDe
$inviteeModuleId = $invitee->related_invitee_module_id;
$personBean = BeanFactory::getBean($inviteeModule, $inviteeModuleId);
// The original email reminders check the accept_status field in related users/leads/contacts etc. and filtered these users who not decline this event.
if ($checkDecline && !self::isDecline($event, $personBean)) {
if (!empty($personBean->email1)) {
$arr = array(
'type' => $inviteeModule,
'name' => $personBean->full_name,
'email' => $personBean->email1,
);
$emails[] = $arr;

// Avoid sending the reminder to any guest if the guest does not already exist in the CRM, as it causes an error that prevents the “Run Email Reminder Notifications” task from finishing correctly
// Prevent a deleted contact, user, etc. from being deleted in order for the task to run
if($personBean != false) {
if ($checkDecline && !self::isDecline($event, $personBean)) {
if (!empty($personBean->email1)) {
$arr = array(
'type' => $inviteeModule,
'name' => $personBean->full_name,
'email' => $personBean->email1,
);
$emails[] = $arr;
}
}
}
}
Expand All @@ -265,7 +270,9 @@ private static function getUnsentEmailReminders()
if ($eventBean) {
$remind_ts = $timedate->fromUser($eventBean->date_start)->modify("-{$reminderBean->timer_email} seconds")->ts;
$now_ts = $timedate->getNow()->ts;
if ($now_ts >= $remind_ts) {
// Do not send a reminder if the meeting has already taken place
$event_ts = $timedate->fromUser($eventBean->date_start)->ts;
if ($now_ts >= $remind_ts && $now_ts <= $event_ts) {
$reminders[$reminderBean->id] = $reminderBean;
}
} else {
Expand Down