From: Tim Düsterhus Date: Mon, 29 Jun 2020 14:11:11 +0000 (+0200) Subject: Add List-Unsubscribe header X-Git-Tag: 5.3.0_Alpha_1~168^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9d3751812c08bf9888ba372dbb8fa02a87f11a36;p=GitHub%2FWoltLab%2FWCF.git Add List-Unsubscribe header Resolves #3379 --- diff --git a/wcfsetup/install/files/lib/system/cronjob/DailyMailNotificationCronjob.class.php b/wcfsetup/install/files/lib/system/cronjob/DailyMailNotificationCronjob.class.php index aac7ac0c02..deed3785b4 100644 --- a/wcfsetup/install/files/lib/system/cronjob/DailyMailNotificationCronjob.class.php +++ b/wcfsetup/install/files/lib/system/cronjob/DailyMailNotificationCronjob.class.php @@ -7,12 +7,14 @@ use wcf\data\user\User; use wcf\data\user\UserEditor; use wcf\data\user\UserList; use wcf\data\user\UserProfile; +use wcf\form\NotificationUnsubscribeForm; use wcf\system\cache\runtime\UserProfileRuntimeCache; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\email\mime\MimePartFacade; use wcf\system\email\mime\RecipientAwareTextMimePart; use wcf\system\email\Email; use wcf\system\email\UserMailbox; +use wcf\system\request\LinkHandler; use wcf\system\user\notification\event\IUserNotificationEvent; use wcf\system\user\notification\UserNotificationHandler; use wcf\system\WCF; @@ -213,6 +215,10 @@ class DailyMailNotificationCronjob extends AbstractCronjob { $email->setSubject($user->getLanguage()->getDynamicVariable('wcf.user.notification.mail.daily.subject', ['count' => count($notifications)])); $email->addRecipient(new UserMailbox($user)); $email->setListID('daily.notification'); + $email->setListUnsubscribe(LinkHandler::getInstance()->getControllerLink(NotificationUnsubscribeForm::class, [ + 'userID' => $user->userID, + 'token' => $user->notificationMailToken, + ]), true); $html = new RecipientAwareTextMimePart('text/html', 'email_dailyNotification', 'wcf', ['notifications' => $notifications]); $plainText = new RecipientAwareTextMimePart('text/plain', 'email_dailyNotification', 'wcf', ['notifications' => $notifications]); 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 f554090071..3f229b6039 100644 --- a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php @@ -9,6 +9,7 @@ use wcf\data\user\notification\UserNotificationAction; use wcf\data\user\User; use wcf\data\user\UserEditor; use wcf\data\user\UserProfile; +use wcf\form\NotificationUnsubscribeForm; use wcf\system\background\job\NotificationEmailDeliveryBackgroundJob; use wcf\system\background\BackgroundQueueHandler; use wcf\system\cache\builder\UserNotificationEventCacheBuilder; @@ -697,6 +698,15 @@ class UserNotificationHandler extends SingletonFactory { $email->addRecipient(new UserMailbox($user)); $humanReadableListId = $user->getLanguage()->getDynamicVariable('wcf.user.notification.'.$event->objectType.'.'.$event->eventName); $email->setListID($event->eventName.'.'.$event->objectType.'.instant.notification', $humanReadableListId); + $email->setListUnsubscribe(LinkHandler::getInstance()->getControllerLink(NotificationUnsubscribeForm::class, [ + // eventID is not part of the parameter list, because we can't communicate that + // only a single type would be unsubscribed. + // The recipient's expectations when performing the One-Click unsubscribing are that + // no further emails will be received. Not following that expectation might result in + // harsh filtering. + 'userID' => $user->userID, + 'token' => $user->notificationMailToken, + ]), true); $message = $event->getEmailMessage('instant'); if (is_array($message)) {