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;
$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]);
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;
$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)) {