Resolve review requests for List-Unsubscribe
authorTim Düsterhus <duesterhus@woltlab.com>
Thu, 2 Jul 2020 11:42:07 +0000 (13:42 +0200)
committerGitHub <noreply@github.com>
Thu, 2 Jul 2020 11:42:07 +0000 (13:42 +0200)
Co-authored-by: Alexander Ebert <ebert@woltlab.com>
com.woltlab.wcf/templates/notificationUnsubscribe.tpl
wcfsetup/install/files/lib/form/NotificationUnsubscribeForm.class.php
wcfsetup/install/files/lib/system/email/Email.class.php

index b15a2820cd0e49d31cdbd1c426cfb32b299d8e4e..d09fd53fb7f85a7afce1664327c70a4e82e15886 100644 (file)
@@ -21,7 +21,7 @@
 
        <div class="formSubmit">
                <input type="submit" value="{lang}wcf.user.notification.mail.unsubscribe.confirm{/lang}" accesskey="s">
-               {* The tag technically is not required, but the POST data is empty otherwise. *}
+               {* The tag is not technically required, but the POST data would be empty otherwise. *}
                {@SECURITY_TOKEN_INPUT_TAG}
        </div>
 </form>
index e948a5e27922ec389d7509de2da092e424c5e2da..e0490c56558bc3b4e3a9b6d068b278afcf11fcd1 100644 (file)
@@ -20,7 +20,6 @@ use wcf\util\StringUtil;
  */
 class NotificationUnsubscribeForm extends AbstractForm {
        /**
-        * user to unsubscribe
         * @var User
         */
        public $user;
@@ -32,7 +31,6 @@ class NotificationUnsubscribeForm extends AbstractForm {
        public $token = '';
        
        /**
-        * whether this is a one-click request
         * @var boolean
         */
        public $isOneClick = false;
@@ -41,7 +39,7 @@ class NotificationUnsubscribeForm extends AbstractForm {
         * notification event to unsubscribe
         * @var UserNotificationEvent
         */
-       public $event = null;
+       public $event;
        
        /**
         * Disable security token validation.
@@ -81,7 +79,7 @@ class NotificationUnsubscribeForm extends AbstractForm {
                        }
                }
                
-               if (!$this->user || !hash_equals($this->user->notificationMailToken, $this->token)) {
+               if (!hash_equals($this->user->notificationMailToken, $this->token)) {
                        throw new IllegalLinkException();
                }
                
@@ -120,6 +118,9 @@ class NotificationUnsubscribeForm extends AbstractForm {
                $this->saved();
                
                if ($this->isOneClick) {
+                       // One-Click unsubscriptions are sent by the recipient's MUA upon clicking a button.
+                       // No additional information except the URI are available and specifically no user interaction can happen.
+                       // Just send a lightweight 204 No Content response, instead of kilobytes of HTML to save on resources.
                        header('HTTP/1.0 204 No Content');
                        exit;
                }
index e1bb8979ea1141a19aecab5e1881f0d145511e69..18919c5be3926a409a02d6d448596a7a037fe943 100644 (file)
@@ -62,21 +62,21 @@ class Email {
         * @var string
         * @since 5.3
         */
-       protected $listId = null;
+       protected $listId;
        
        /**
         * Human readable part of the List-Id header
         * @var string
         * @since 5.3
         */
-       protected $listIdHuman = null;
+       protected $listIdHuman;
        
        /**
         * List-Unsubscribe URI
         * @var string
         * @since 5.3
         */
-       protected $listUnsubscribe = null;
+       protected $listUnsubscribe;
        
        /**
         * Whether the listUnsubscribe URI has One-Click support