Skip to content
Open
Changes from 1 commit
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
12 changes: 11 additions & 1 deletion lib/MailQueueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm
// No users found to notify, mission abort
return 0;
}
$this->logger->debug('Sending notification emails to users: '. implode("|",$affectedUsers));

$userLanguages = $this->config->getUserValueForUsers('core', 'lang', $affectedUsers);
$userTimezones = $this->config->getUserValueForUsers('core', 'timezone', $affectedUsers);
Expand Down Expand Up @@ -177,6 +178,7 @@ public function sendEmails($limit, $sendTime, $forceSending = false, $restrictEm
}
$this->activityManager->setRequirePNG(false);

$this->logger->debug('eMail notifications sent. Will delete: ' . implode("|",$deleteItemsForUsers));
// Delete all entries we dealt with
$this->deleteSentItems($deleteItemsForUsers, $sendTime);

Expand Down Expand Up @@ -405,6 +407,12 @@ protected function sendEmailToUser($userName, $email, $lang, $timezone, $maxTime
try {
$this->mailer->send($message);
} catch (\Exception $e) {
$this->logger->logException($e, [
'message' => 'Failed sending email to user "{user}"',
'user' => $user,
Copy link
Contributor

@kesselb kesselb Jun 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log the exception with $this->logger->logException($e); and log a additional warning $this->logger->warning('Failed to send notification email for user {user}', ['user' => $userName]);. You cannot use $user because it's a IUser object. Ah that might work as the normalizer will format it. I would still prefer the $userName ;)

'app' => 'activity',
]);
$this->activityManager->setCurrentUserId(null);
return false;
}

Expand Down Expand Up @@ -498,6 +506,8 @@ protected function deleteSentItems(array $affectedUsers, $maxTime) {
$query->delete('activity_mq')
->where($query->expr()->lte('amq_timestamp', $query->createNamedParameter($maxTime, IQueryBuilder::PARAM_INT)))
->andWhere($query->expr()->in('amq_affecteduser', $query->createNamedParameter($affectedUsers, IQueryBuilder::PARAM_STR_ARRAY), IQueryBuilder::PARAM_STR));
$query->execute();
$this->logger->debug('Delete SQL: ' . $query->getSQL());
$result = $query->execute();
$this->logger->debug('Delete Statement returned: ' . $result);
}
}