From 54b97c216ee45d61cd8c02d61afbd1b33d1f6942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 11 Jul 2024 10:06:27 +0200 Subject: [PATCH 1/2] fix: Catch exceptions thrown by NotificationMail constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously when constructor would throw, it would stop there and on the next run the notifications before the broken one would get resent. Exceptions from constructor are now caught and the process continues. Signed-off-by: Côme Chilliet --- lib/Service/MailService.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/Service/MailService.php b/lib/Service/MailService.php index 020c443a1..7fd39db84 100644 --- a/lib/Service/MailService.php +++ b/lib/Service/MailService.php @@ -156,15 +156,14 @@ public function sendNotifications(): void { } foreach ($subscriptions as $subscription) { - $subscription->setNotifyLogs($this->logs); - $notication = new NotificationMail($subscription); - try { + $subscription->setNotifyLogs($this->logs); + $notication = new NotificationMail($subscription); $notication->send(); } catch (InvalidEmailAddress $e) { - $this->logger->warning('Invalid or no email address for notification: ' . json_encode($subscription)); + $this->logger->warning('Invalid or no email address for notification: ' . json_encode($subscription), ['exception' => $e]); } catch (\Exception $e) { - $this->logger->error('Error sending notification to ' . json_encode($subscription)); + $this->logger->error('Error sending notification to ' . json_encode($subscription), ['exception' => $e]); continue; } } From 7afcca0438ad6f14c9f5c9c3c32a4aba80ba4312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Gieling?= <26707476+dartcafe@users.noreply.github.com> Date: Mon, 15 Jul 2024 20:28:08 +0200 Subject: [PATCH 2/2] Update MailService.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixed typo Signed-off-by: René Gieling <26707476+dartcafe@users.noreply.github.com> --- lib/Service/MailService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Service/MailService.php b/lib/Service/MailService.php index 7fd39db84..df0a52ff0 100644 --- a/lib/Service/MailService.php +++ b/lib/Service/MailService.php @@ -158,8 +158,8 @@ public function sendNotifications(): void { foreach ($subscriptions as $subscription) { try { $subscription->setNotifyLogs($this->logs); - $notication = new NotificationMail($subscription); - $notication->send(); + $notification = new NotificationMail($subscription); + $notification->send(); } catch (InvalidEmailAddress $e) { $this->logger->warning('Invalid or no email address for notification: ' . json_encode($subscription), ['exception' => $e]); } catch (\Exception $e) {