From 27fb0b8cd3033eafc0bdf60f0b3b25504fe26a2b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Sat, 18 Jun 2016 15:48:03 +0200 Subject: [PATCH] Use a fixed message-id in UserProfileCommentUserNotificationEvent --- .../UserNotificationHandler.class.php | 10 +++++++++- .../event/IUserNotificationEvent.class.php | 15 ++++++++++++--- ...rProfileCommentUserNotificationEvent.class.php | 1 + 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php index 4682001aaa..28be7619b0 100644 --- a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php @@ -664,7 +664,6 @@ class UserNotificationHandler extends SingletonFactory { 'title' => $event->getEmailTitle() ])); $email->addRecipient(new UserMailbox($user)); - // TODO: MessageID, References, In-Reply-To $message = $event->getEmailMessage('instant'); if (is_array($message)) { @@ -676,6 +675,15 @@ class UserNotificationHandler extends SingletonFactory { if (isset($message['variables'])) { $variables['variables'] = $message['variables']; } + if (isset($message['message-id'])) { + $email->setMessageID($message['message-id']); + } + if (isset($message['in-reply-to'])) { + foreach ($message['in-reply-to'] as $inReplyTo) $email->addInReplyTo($inReplyTo); + } + if (isset($message['references'])) { + foreach ($message['references'] as $references) $email->addReferences($references); + } $html = new RecipientAwareTextMimePart('text/html', 'email_notification', 'wcf', $variables); $plainText = new RecipientAwareTextMimePart('text/plain', 'email_notification', 'wcf', $variables); diff --git a/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php index 3b7c975c09..e510b4327e 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php @@ -51,16 +51,25 @@ interface IUserNotificationEvent extends IDatabaseObjectProcessor { * * If $notificationType is 'instant' this method should either: * - Return a string to be inserted into a text/plain email (deprecated) - * - Return a ['template' => ..., 'application' => ..., 'variables' => ...] array - * to be included into the summary email. + * - Return an ['template' => ..., + * 'application' => ..., + * 'variables' => ..., + * 'message-id' => ..., + * 'in-reply-to' => [...], + * 'references' => [...]] + * array to be included into the notification email. + * message-id, in-reply-to and references refer to the respective headers + * of an email and are optional. You MUST NOT generate a message-id if you + * cannot ensure that it will *never* repeat. * * If $notificationType is 'daily' this method should either: * - Return a string to be inserted into the summary email (deprecated) - * - Return a ['template' => ..., 'application' => ..., 'variables' => ...] array + * - Return an ['template' => ..., 'application' => ..., 'variables' => ...] array * to be included into the summary email. * * @param string $notificationType * @return mixed + * @see \wcf\system\email\Email */ public function getEmailMessage($notificationType = 'instant'); diff --git a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php index ad15f67d36..2e61a2bbb9 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php @@ -73,6 +73,7 @@ class UserProfileCommentUserNotificationEvent extends AbstractSharedUserNotifica */ public function getEmailMessage($notificationType = 'instant') { return [ + 'message-id' => 'com.woltlab.wcf.user.profileComment.notification/'.$this->getUserNotificationObject()->commentID, 'template' => 'email_notification_userProfileComment', 'application' => 'wcf', 'variables' => [ -- 2.20.1