Use a fixed message-id in UserProfileCommentUserNotificationEvent
authorTim Düsterhus <duesterhus@woltlab.com>
Sat, 18 Jun 2016 13:48:03 +0000 (15:48 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 29 Jul 2016 14:25:53 +0000 (16:25 +0200)
wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php
wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php
wcfsetup/install/files/lib/system/user/notification/event/UserProfileCommentUserNotificationEvent.class.php

index 4682001aaab8279cb4af3124939b5d52886a5284..28be7619b0e451d4421625f74b8e15ab780e7f89 100644 (file)
@@ -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);
index 3b7c975c0984f81efeda6a3ed8536dc4816d6db2..e510b4327ed8912e7d20649abc578d24b8ccf739 100644 (file)
@@ -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');
        
index ad15f67d366855eb1c047ebc7bf62c05d6f1b406..2e61a2bbb9fde0d9131f5a494a99961da1a6c2b7 100644 (file)
@@ -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' => [