Fix issue when sending notifications about moderation comments
authorMarcel Werk <burntime@woltlab.com>
Thu, 8 Feb 2024 13:25:06 +0000 (14:25 +0100)
committerOlaf Braun <info@braun-development.de>
Thu, 7 Mar 2024 15:36:58 +0000 (16:36 +0100)
If the e-mail notifications were created as a daily summary, the use of `ViewableModerationQueue::getViewableModerationQueue()` was not reliable, as the ID of the activate user was used there.

wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentResponseUserNotificationEvent.class.php
wcfsetup/install/files/lib/system/user/notification/event/ModerationQueueCommentUserNotificationEvent.class.php

index b7614307890656658ef0bd20647788c5708746e9..f80e501147fe8ee256752608a6516421d651e17b 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace wcf\system\user\notification\event;
 
+use wcf\data\moderation\queue\ModerationQueue;
 use wcf\data\moderation\queue\ViewableModerationQueue;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\user\UserProfile;
@@ -57,7 +58,7 @@ class ModerationQueueCommentResponseUserNotificationEvent extends AbstractCommen
      */
     public function checkAccess()
     {
-        if (!WCF::getSession()->getPermission('mod.general.canUseModeration') || $this->getModerationQueue() === null) {
+        if (!WCF::getSession()->getPermission('mod.general.canUseModeration')) {
             return false;
         }
 
@@ -161,7 +162,7 @@ class ModerationQueueCommentResponseUserNotificationEvent extends AbstractCommen
         if (!$this->moderationQueueLoaded) {
             $comment = CommentRuntimeCache::getInstance()->getObject($this->getUserNotificationObject()->commentID);
 
-            $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue($comment->objectID);
+            $this->moderationQueue = new ViewableModerationQueue(new ModerationQueue($comment->objectID));
             $this->moderationQueueLoaded = true;
         }
 
index 886cea99174f1437451732ad703dafecd4c20f81..d207b4f45b624a46c3d20b9b1d804b8a129e9313 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace wcf\system\user\notification\event;
 
+use wcf\data\moderation\queue\ModerationQueue;
 use wcf\data\moderation\queue\ViewableModerationQueue;
 use wcf\data\object\type\ObjectTypeCache;
 use wcf\data\user\notification\UserNotification;
@@ -51,7 +52,7 @@ class ModerationQueueCommentUserNotificationEvent extends AbstractCommentUserNot
      */
     public function checkAccess()
     {
-        if ($this->moderationQueue === null || !WCF::getSession()->getPermission('mod.general.canUseModeration')) {
+        if (!WCF::getSession()->getPermission('mod.general.canUseModeration')) {
             return false;
         }
 
@@ -139,19 +140,16 @@ class ModerationQueueCommentUserNotificationEvent extends AbstractCommentUserNot
     ) {
         parent::setObject($notification, $object, $author, $additionalData);
 
-        // if the active user has no access, $this->moderationQueue is null
-        $this->moderationQueue = ViewableModerationQueue::getViewableModerationQueue(
-            $this->getUserNotificationObject()->objectID
+        $this->moderationQueue = new ViewableModerationQueue(
+            new ModerationQueue($this->getUserNotificationObject()->objectID)
         );
 
-        if ($this->moderationQueue) {
-            /** @var IModerationQueueHandler $moderationHandler */
-            $moderationHandler = ObjectTypeCache::getInstance()
-                ->getObjectType($this->moderationQueue->objectTypeID)
-                ->getProcessor();
-            $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix();
-            $this->typeName = $this->getLanguage()->get($moderationHandler->getCommentNotificationTypeNameLanguageItem());
-        }
+        /** @var IModerationQueueHandler $moderationHandler */
+        $moderationHandler = ObjectTypeCache::getInstance()
+            ->getObjectType($this->moderationQueue->objectTypeID)
+            ->getProcessor();
+        $this->languageItemPrefix = $moderationHandler->getCommentNotificationLanguageItemPrefix();
+        $this->typeName = $this->getLanguage()->get($moderationHandler->getCommentNotificationTypeNameLanguageItem());
     }
 
     /**