From: joshuaruesweg
Date: Mon, 13 Sep 2021 09:42:37 +0000 (+0200)
Subject: Add notification for comments in subscribed article categories
X-Git-Tag: 5.5.0_Alpha_1~447^2
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=79ad63d3873c9589169fc5b56175faf531731f8e;p=GitHub%2FWoltLab%2FWCF.git
Add notification for comments in subscribed article categories
---
diff --git a/wcfsetup/install/files/lib/system/user/notification/object/type/ArticleCommentUserNotificationObjectType.class.php b/wcfsetup/install/files/lib/system/user/notification/object/type/ArticleCommentUserNotificationObjectType.class.php
index 84c83069b6..82ddef7cec 100644
--- a/wcfsetup/install/files/lib/system/user/notification/object/type/ArticleCommentUserNotificationObjectType.class.php
+++ b/wcfsetup/install/files/lib/system/user/notification/object/type/ArticleCommentUserNotificationObjectType.class.php
@@ -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);
+ }
}
diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml
index 588aaa3b60..d412d30947 100644
--- a/wcfsetup/install/lang/de.xml
+++ b/wcfsetup/install/lang/de.xml
@@ -5406,10 +5406,10 @@ Benachrichtigungen auf {PAGE_TITLE|lang
- - userID}{$author}{else}Ein Gast{/if} hat einen Kommentar zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel {$article->getTitle()} verfasst.]]>
- - {$article->getTitle()} verfasst.]]>
- - 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}]]>
- - {@$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()} verfasst:
]]>
+ - userID}{$author}{else}Ein Gast{/if} hat einen Kommentar zu dem Artikel {$article->getTitle()} verfasst.]]>
+ - {$article->getTitle()} verfasst.]]>
+ - 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}]]>
+ - {@$authorList} {if $count == 1 && $guestTimesTriggered < 2 && (!$event->getAuthor()->userID || $guestTimesTriggered == 0)}hat einen Kommentar{else}haben Kommentare{/if} zu dem Artikel {$article->getTitle()} verfasst:]]>
- userID}{$author}{else}Ein Gast{/if} hat eine Antwort zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Kommentar in dem Artikel {$article->getTitle()} verfasst.]]>
@@ -5429,7 +5429,7 @@ Benachrichtigungen auf {PAGE_TITLE|lang
- {$author} hat den Artikel {$articleContent->getTitle()} verfasst:]]>
-
+
- {$author} hat sich registriert.]]>
diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml
index 063c251e45..e02b1a0cee 100644
--- a/wcfsetup/install/lang/en.xml
+++ b/wcfsetup/install/lang/en.xml
@@ -5406,10 +5406,10 @@ your notifications on {PAGE_TITLE|langu
- - userID}{$author}{else}A guest{/if} commented on your article {$article->getTitle()}.]]>
- - {$article->getTitle()}.]]>
- - getTitle()}â [URL:{@$article->getLink()}#comment{@$commentID}]{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
- - {@$authorList} commented on your article {$article->getTitle()}:]]>
+ - userID}{$author}{else}A guest{/if} commented on the article {$article->getTitle()}.]]>
+ - {$article->getTitle()}.]]>
+ - getTitle()}â [URL:{@$article->getLink()}#comment{@$commentID}]{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
+ - {@$authorList} commented on the article {$article->getTitle()}:]]>
- userID}{$author}{else}A guest{/if} replied to your comment on the article {$article->getTitle()}.]]>
@@ -5429,7 +5429,7 @@ your notifications on {PAGE_TITLE|langu
- {$author} wrote the article {$articleContent->getTitle()}:]]>
-
+