Add notification for comments in subscribed article categories
authorjoshuaruesweg <ruesweg@woltlab.com>
Mon, 13 Sep 2021 09:42:37 +0000 (11:42 +0200)
committerjoshuaruesweg <ruesweg@woltlab.com>
Thu, 16 Sep 2021 14:47:36 +0000 (16:47 +0200)
wcfsetup/install/files/lib/system/user/notification/object/type/ArticleCommentUserNotificationObjectType.class.php
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 84c83069b64880bce00e9293b4b13f836f0ec850..82ddef7cec55a755c4ff7fb28f7f95e4f4d6fe04 100644 (file)
@@ -2,8 +2,10 @@
 
 namespace wcf\system\user\notification\object\type;
 
+use wcf\data\article\content\ArticleContent;
 use wcf\data\comment\Comment;
 use wcf\data\comment\CommentList;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
 use wcf\system\user\notification\object\CommentUserNotificationObject;
 use wcf\system\WCF;
 
@@ -17,7 +19,8 @@ use wcf\system\WCF;
  * @since       5.2
  */
 class ArticleCommentUserNotificationObjectType extends AbstractUserNotificationObjectType implements
-    ICommentUserNotificationObjectType
+    ICommentUserNotificationObjectType,
+    IMultiRecipientCommentUserNotificationObjectType
 {
     /**
      * @inheritDoc
@@ -49,4 +52,30 @@ class ArticleCommentUserNotificationObjectType extends AbstractUserNotificationO
 
         return $statement->fetchSingleColumn() ?: 0;
     }
+
+    /**
+     * @inheritDoc
+     */
+    public function getRecipientIDs(Comment $comment)
+    {
+        $articleContent = new ArticleContent($comment->objectID);
+        $article = $articleContent->getArticle();
+
+        \assert($article->articleID !== 0);
+
+        $subscribers = $article->getCategory()->getSubscribedUserIDs();
+
+        $users = UserProfileRuntimeCache::getInstance()->getObjects($subscribers);
+
+        // Add the article author to the recipients, to ensure, that he
+        // receive a notifications, even if he has not subscribed the category.
+        $recipients = [$article->getUserID()];
+        foreach ($users as $user) {
+            if ($article->canRead($user)) {
+                $recipients[] = $user->userID;
+            }
+        }
+
+        return \array_unique($recipients);
+    }
 }
index 588aaa3b6066e3d4eddc3a17a5b5017ff2d5002c..d412d309476e4e3ed6036705009037f1397def44 100644 (file)
@@ -5406,10 +5406,10 @@ Benachrichtigungen auf <a href="{link isHtmlEmail=true}{/link}">{PAGE_TITLE|lang
                <item name="wcf.user.notification.com.woltlab.wcf.article.comment.response.notification.commentResponseOwner"><![CDATA[Neue Antwort auf einen Kommentar zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel]]></item>
                <item name="wcf.user.notification.articleComment.title"><![CDATA[Neuer Kommentar (Artikel)]]></item>
                <item name="wcf.user.notification.articleComment.title.stacked"><![CDATA[{#$timesTriggered} neue Kommentare (Artikel)]]></item>
-               <item name="wcf.user.notification.articleComment.message"><![CDATA[{if $author->userID}<strong>{$author}</strong>{else}Ein Gast{/if} hat einen Kommentar zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel <strong>{$article->getTitle()}</strong> verfasst.]]></item>
-               <item name="wcf.user.notification.articleComment.message.stacked"><![CDATA[{@'wcf.user.notification.stacked.authorList'|language} haben Kommentare zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel <strong>{$article->getTitle()}</strong> verfasst.]]></item>
-               <item name="wcf.user.notification.articleComment.mail.plaintext"><![CDATA[{@$authorList} {if $count == 1 && $guestTimesTriggered < 2 && (!$event->getAuthor()->userID || $guestTimesTriggered == 0)}hat einen Kommentar{else}haben Kommentare{/if} zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel „{@$article->getTitle()}“ [URL:{@$article->getLink()}#comment{@$commentID}] verfasst{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]></item>
-               <item name="wcf.user.notification.articleComment.mail.html"><![CDATA[<p>{@$authorList} {if $count == 1 && $guestTimesTriggered < 2 && (!$event->getAuthor()->userID || $guestTimesTriggered == 0)}hat einen Kommentar{else}haben Kommentare{/if} zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel <a href="{$article->getLink()}#comment{@$commentID}">{$article->getTitle()}</a> verfasst:</p>]]></item>
+               <item name="wcf.user.notification.articleComment.message"><![CDATA[{if $author->userID}<strong>{$author}</strong>{else}Ein Gast{/if} hat einen Kommentar zu dem Artikel <strong>{$article->getTitle()}</strong> verfasst.]]></item>
+               <item name="wcf.user.notification.articleComment.message.stacked"><![CDATA[{@'wcf.user.notification.stacked.authorList'|language} haben Kommentare zu dem Artikel <strong>{$article->getTitle()}</strong> verfasst.]]></item>
+               <item name="wcf.user.notification.articleComment.mail.plaintext"><![CDATA[{@$authorList} {if $count == 1 && $guestTimesTriggered < 2 && (!$event->getAuthor()->userID || $guestTimesTriggered == 0)}hat einen Kommentar{else}haben Kommentare{/if} zu dem Artikel „{@$article->getTitle()}“ [URL:{@$article->getLink()}#comment{@$commentID}] verfasst{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]></item>
+               <item name="wcf.user.notification.articleComment.mail.html"><![CDATA[<p>{@$authorList} {if $count == 1 && $guestTimesTriggered < 2 && (!$event->getAuthor()->userID || $guestTimesTriggered == 0)}hat einen Kommentar{else}haben Kommentare{/if} zu dem Artikel <a href="{$article->getLink()}#comment{@$commentID}">{$article->getTitle()}</a> verfasst:</p>]]></item>
                <item name="wcf.user.notification.articleComment.response.title"><![CDATA[Neue Antwort (Artikel)]]></item>
                <item name="wcf.user.notification.articleComment.response.title.stacked"><![CDATA[{#$timesTriggered} neue Antworten (Artikel)]]></item>
                <item name="wcf.user.notification.articleComment.response.message"><![CDATA[{if $author->userID}<strong>{$author}</strong>{else}Ein Gast{/if} hat eine Antwort zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Kommentar in dem Artikel <strong>{$article->getTitle()}</strong> verfasst.]]></item>
@@ -5429,7 +5429,7 @@ Benachrichtigungen auf <a href="{link isHtmlEmail=true}{/link}">{PAGE_TITLE|lang
                <item name="wcf.user.notification.article.mail.html"><![CDATA[<p><strong>{$author}</strong> hat den Artikel <a href="{$articleContent->getLink()}">{$articleContent->getTitle()}</a> verfasst:</p>]]></item>
                <item name="wcf.user.notification.com.woltlab.wcf.articleComment.response.notification.commentResponseOwner"><![CDATA[Neue Antwort auf einen Kommentar zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel]]></item>
                <item name="wcf.user.notification.com.woltlab.wcf.articleComment.response.notification.commentResponse"><![CDATA[Neue Antwort auf einen Kommentar von {if LANGUAGE_USE_INFORMAL_VARIANT}dir{else}Ihnen{/if}]]></item>
-               <item name="wcf.user.notification.com.woltlab.wcf.articleComment.notification.comment"><![CDATA[Neuer Kommentar zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel]]></item>
+               <item name="wcf.user.notification.com.woltlab.wcf.articleComment.notification.comment"><![CDATA[Neuer Kommentar zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel und Artikeln aus abonnierten Kategorien]]></item>
                <item name="wcf.user.notification.userRegistration.title"><![CDATA[Neue Benutzer-Registrierung]]></item>
                <item name="wcf.user.notification.userRegistration.title.stacked"><![CDATA[{#$count} neue Benutzer-Registrierungen]]></item>
                <item name="wcf.user.notification.userRegistration.message"><![CDATA[<strong>{$author}</strong> hat sich registriert.]]></item>
index 063c251e454ea506643c9f701e007c28df9d5494..e02b1a0ceec16c097a5c83adfa863ad94ab463e3 100644 (file)
@@ -5406,10 +5406,10 @@ your notifications on <a href="{link isHtmlEmail=true}{/link}">{PAGE_TITLE|langu
                <item name="wcf.user.notification.com.woltlab.wcf.article.comment.response.notification.commentResponseOwner"><![CDATA[Notify me of new replies to comments on my articles]]></item>
                <item name="wcf.user.notification.articleComment.title"><![CDATA[New Comment (Article)]]></item>
                <item name="wcf.user.notification.articleComment.title.stacked"><![CDATA[{#$timesTriggered} new Comments (Article)]]></item>
-               <item name="wcf.user.notification.articleComment.message"><![CDATA[{if $author->userID}<strong>{$author}</strong>{else}A guest{/if} commented on your article <strong>{$article->getTitle()}</strong>.]]></item>
-               <item name="wcf.user.notification.articleComment.message.stacked"><![CDATA[{@'wcf.user.notification.stacked.authorList'|language} commented on your article <strong>{$article->getTitle()}</strong>.]]></item>
-               <item name="wcf.user.notification.articleComment.mail.plaintext"><![CDATA[{@$authorList} commented on your article “{@$article->getTitle()}” [URL:{@$article->getLink()}#comment{@$commentID}]{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]></item>
-               <item name="wcf.user.notification.articleComment.mail.html"><![CDATA[<p>{@$authorList} commented on your article <a href="{$article->getLink()}#comments/comment{@$commentID}">{$article->getTitle()}</a>:</p>]]></item>
+               <item name="wcf.user.notification.articleComment.message"><![CDATA[{if $author->userID}<strong>{$author}</strong>{else}A guest{/if} commented on the article <strong>{$article->getTitle()}</strong>.]]></item>
+               <item name="wcf.user.notification.articleComment.message.stacked"><![CDATA[{@'wcf.user.notification.stacked.authorList'|language} commented on the article <strong>{$article->getTitle()}</strong>.]]></item>
+               <item name="wcf.user.notification.articleComment.mail.plaintext"><![CDATA[{@$authorList} commented on the article “{@$article->getTitle()}” [URL:{@$article->getLink()}#comment{@$commentID}]{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]></item>
+               <item name="wcf.user.notification.articleComment.mail.html"><![CDATA[<p>{@$authorList} commented on the article <a href="{$article->getLink()}#comments/comment{@$commentID}">{$article->getTitle()}</a>:</p>]]></item>
                <item name="wcf.user.notification.articleComment.response.title"><![CDATA[New Reply (Article)]]></item>
                <item name="wcf.user.notification.articleComment.response.title.stacked"><![CDATA[{#$timesTriggered} new Replies (Article)]]></item>
                <item name="wcf.user.notification.articleComment.response.message"><![CDATA[{if $author->userID}<strong>{$author}</strong>{else}A guest{/if} replied to your comment on the article <strong>{$article->getTitle()}</strong>.]]></item>
@@ -5429,7 +5429,7 @@ your notifications on <a href="{link isHtmlEmail=true}{/link}">{PAGE_TITLE|langu
                <item name="wcf.user.notification.article.mail.html"><![CDATA[<p><strong>{$author}</strong> wrote the article <a href="{$articleContent->getLink()}">{$articleContent->getTitle()}</a>:</p>]]></item>
                <item name="wcf.user.notification.com.woltlab.wcf.articleComment.response.notification.commentResponseOwner"><![CDATA[Notify me of new replies to comments on my articles]]></item>
                <item name="wcf.user.notification.com.woltlab.wcf.articleComment.response.notification.commentResponse"><![CDATA[Notify me of new replies to my comments]]></item>
-               <item name="wcf.user.notification.com.woltlab.wcf.articleComment.notification.comment"><![CDATA[Notify me of new comments on my articles]]></item>
+               <item name="wcf.user.notification.com.woltlab.wcf.articleComment.notification.comment"><![CDATA[Notify me of new comments on my articles and on articles in subscribed categories]]></item>
                <item name="wcf.user.notification.pageComment.responseOwner.title"><![CDATA[New reply (Page)]]></item>
                <item name="wcf.user.notification.userRegistration.title"><![CDATA[New user registration]]></item>
                <item name="wcf.user.notification.userRegistration.title.stacked"><![CDATA[{#$count} new user registrations]]></item>