Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/notifications.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-10-06 09:44:14 +0300
committerJoas Schilling <coding@schilljs.com>2022-10-06 09:44:14 +0300
commit98e25e706bf5a8f6f92d532dc0cba33daaf42b21 (patch)
tree4cd93ca8a968fc53bc257b991910c2a66654c58a
parent21b0ae2be952445aa35d3150c5a0b8bfbc1f10c9 (diff)
Improve debugging of failing emails
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/MailNotifications.php27
1 files changed, 19 insertions, 8 deletions
diff --git a/lib/MailNotifications.php b/lib/MailNotifications.php
index 990ec6b..7fad5e0 100644
--- a/lib/MailNotifications.php
+++ b/lib/MailNotifications.php
@@ -276,15 +276,26 @@ class MailNotifications {
$notifications = array_reverse($notifications);
foreach ($notifications as $notification) {
- $relativeDateTime = $this->dateFormatter->formatDateTimeRelativeDay($notification->getDateTime(), 'long', 'short', new \DateTimeZone($timezone), $l10n);
- $template->addBodyListItem($this->getHTMLContents($notification), $relativeDateTime, $notification->getIcon(), $notification->getParsedSubject());
-
- // Buttons probably were not intended for this, but it works ok enough for showing the idea.
- $actions = $notification->getParsedActions();
- foreach ($actions as $action) {
- if ($action->getRequestType() === IAction::TYPE_WEB) {
- $template->addBodyButton($action->getLabel(), $action->getLink());
+ try {
+ $relativeDateTime = $this->dateFormatter->formatDateTimeRelativeDay($notification->getDateTime(), 'long', 'short', new \DateTimeZone($timezone), $l10n);
+ $template->addBodyListItem($this->getHTMLContents($notification), $relativeDateTime, $notification->getIcon(), $notification->getParsedSubject());
+
+ // Buttons probably were not intended for this, but it works ok enough for showing the idea.
+ $actions = $notification->getParsedActions();
+ foreach ($actions as $action) {
+ if ($action->getRequestType() === IAction::TYPE_WEB) {
+ $template->addBodyButton($action->getLabel(), $action->getLink());
+ }
}
+ } catch (\Throwable $e) {
+ $this->logger->error(
+ 'An error occurred while preparing a notification ('
+ . $notification->getApp() . '|' . $notification->getSubject()
+ . '|' . $notification->getObjectType() . '|' . $notification->getObjectId()
+ . ') for sending', [
+ 'exception' => $e,
+ ]);
+ return null;
}
}