Fixed Approved posts never send quote or mention alerts

Xon

Well-known member
Affected version
2.0.2
If a user is caught in the approval queue (for example due to a false positive on spam checking), even after approval, their post does not generate expected alerts. As quotes & mentions do not have their extra information gathered

Approved posts do generate reply alerts and watch thread/forum emails, IF it is the very last post.

PHP:
protected function onApprove()
{
// if this is not the last post, then another notification would have been triggered already
if ($this->post->isLastPost())
...
The only invoking the notifier on last post is very heavy weight as XF has a lot of other notifier bits besides last post notify (ie watched forum at message level should generate an alert/email for every post)
 
Last edited:
Diff:
Index: src/XF/Service/Post/Approver.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/XF/Service/Post/Approver.php    (date 1524655588000)
+++ src/XF/Service/Post/Approver.php    (date 1524655229000)
@@ -47,12 +47,8 @@
 
     protected function onApprove()
     {
-        // if this is not the last post, then another notification would have been triggered already
-        if ($this->post->isLastPost())
-        {
-            /** @var \XF\Service\Post\Notifier $notifier */
-            $notifier = $this->service('XF:Post\Notifier', $this->post, 'reply');
-            $notifier->notifyAndEnqueue($this->notifyRunTime);
-        }
+        /** @var \XF\Service\Post\Notifier $notifier */
+        $notifier = $this->service('XF:Post\Notifier', $this->post, 'reply');
+        $notifier->notifyAndEnqueue($this->notifyRunTime);
     }
 }
\ No newline at end of file
Index: src/XF/Service/Post/Notifier.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/XF/Service/Post/Notifier.php    (date 1524655588000)
+++ src/XF/Service/Post/Notifier.php    (date 1524655372000)
@@ -53,12 +53,19 @@
 
     protected function loadNotifiers()
     {
-        return [
+        $notifiers = [
             'quote' => $this->app->notifier('XF:Post\Quote', $this->post),
             'mention' => $this->app->notifier('XF:Post\Mention', $this->post),
-            'threadWatch' => $this->app->notifier('XF:Post\ThreadWatch', $this->post, $this->actionType),
             'forumWatch' => $this->app->notifier('XF:Post\ForumWatch', $this->post, $this->actionType),
         ];
+
+        // if this is not the last post, then another notification would have been triggered already
+        if ($this->post->isLastPost())
+        {
+            $notifiers['threadWatch'] = $this->app->notifier('XF:Post\ThreadWatch', $this->post, $this->actionType);
+        }
+
+        return $notifiers;
     }
 
     protected function loadExtraUserData(array $users)
I think this pretty much does what we want it to do. It means that all notifiers run, except ThreadWatch, in which case that only runs if it is the last post.
 
Back
Top Bottom