From: Marcel Werk
Date: Fri, 6 May 2022 21:47:38 +0000 (+0200)
Subject: Notifications about reactions to article comments
X-Git-Tag: 5.5.0_Beta_1~11^2~1
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7d90ca1d2c1e7b06fa12966991531689624c6f06;p=GitHub%2FWoltLab%2FWCF.git
Notifications about reactions to article comments
---
diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml
index 510afec5dc..64489461c9 100644
--- a/com.woltlab.wcf/objectType.xml
+++ b/com.woltlab.wcf/objectType.xml
@@ -125,6 +125,20 @@
wcf\system\user\notification\object\type\LikeUserNotificationObjectType
com.woltlab.wcf.page
+
+ com.woltlab.wcf.articleComment.like.notification
+ com.woltlab.wcf.notification.objectType
+ wcf\system\user\notification\object\type\LikeUserNotificationObjectType
+ com.woltlab.wcf.page
+ 1
+
+
+ com.woltlab.wcf.articleComment.response.like.notification
+ com.woltlab.wcf.notification.objectType
+ wcf\system\user\notification\object\type\LikeUserNotificationObjectType
+ com.woltlab.wcf.page
+ 1
+
com.woltlab.wcf.article.recentActivityEvent
com.woltlab.wcf.user.recentActivityEvent
diff --git a/com.woltlab.wcf/userNotificationEvent.xml b/com.woltlab.wcf/userNotificationEvent.xml
index 6d2f7ba38f..3a21566bae 100644
--- a/com.woltlab.wcf/userNotificationEvent.xml
+++ b/com.woltlab.wcf/userNotificationEvent.xml
@@ -125,6 +125,20 @@
1
module_like,module_article
+
+ like
+ com.woltlab.wcf.articleComment.like.notification
+ wcf\system\user\notification\event\ArticleCommentLikeUserNotificationEvent
+ 1
+ module_like,module_article
+
+
+ like
+ com.woltlab.wcf.articleComment.response.like.notification
+ wcf\system\user\notification\event\ArticleCommentResponseLikeUserNotificationEvent
+ 1
+ module_like,module_article
+
registration
diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ArticleCommentLikeUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ArticleCommentLikeUserNotificationEvent.class.php
new file mode 100644
index 0000000000..e50081ef74
--- /dev/null
+++ b/wcfsetup/install/files/lib/system/user/notification/event/ArticleCommentLikeUserNotificationEvent.class.php
@@ -0,0 +1,130 @@
+
+ * @package WoltLabSuite\Core\System\User\Notification\Event
+ * @since 5.5
+ *
+ * @method LikeUserNotificationObject getUserNotificationObject()
+ */
+class ArticleCommentLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements
+ ITestableUserNotificationEvent
+{
+ use TTestableCommentLikeUserNotificationEvent;
+ use TTestableArticleCommentUserNotificationEvent;
+ use TReactionUserNotificationEvent;
+
+ /**
+ * @inheritDoc
+ */
+ protected $stackable = true;
+
+ /**
+ * @inheritDoc
+ */
+ protected function prepare()
+ {
+ ViewableArticleContentRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getTitle()
+ {
+ $count = \count($this->getAuthors());
+ if ($count > 1) {
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.like.title.stacked', [
+ 'count' => $count,
+ 'timesTriggered' => $this->notification->timesTriggered,
+ ]);
+ }
+
+ return $this->getLanguage()->get('wcf.user.notification.articleComment.like.title');
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getMessage()
+ {
+ $article = ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
+ $authors = \array_values($this->getAuthors());
+ $count = \count($authors);
+
+ if ($count > 1) {
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.like.message.stacked', [
+ 'author' => $this->author,
+ 'authors' => $authors,
+ 'commentID' => $this->getCommentID(),
+ 'count' => $count,
+ 'others' => $count - 1,
+ 'article' => $article,
+ 'reactions' => $this->getReactionsForAuthors(),
+ ]);
+ }
+
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.like.message', [
+ 'author' => $this->author,
+ 'commentID' => $this->getCommentID(),
+ 'article' => $article,
+ 'reactions' => $this->getReactionsForAuthors(),
+ ]);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getEmailMessage($notificationType = 'instant')
+ {
+ // not supported
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getLink()
+ {
+ return ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink() . '#comment' . $this->getCommentID();
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getEventHash()
+ {
+ return \sha1($this->eventID . '-' . $this->getCommentID());
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function supportsEmailNotification()
+ {
+ return false;
+ }
+
+ /**
+ * Returns the liked comment's id.
+ *
+ * @return int
+ */
+ protected function getCommentID()
+ {
+ // this is the `wcfN_like.objectID` value
+ return $this->getUserNotificationObject()->objectID;
+ }
+}
diff --git a/wcfsetup/install/files/lib/system/user/notification/event/ArticleCommentResponseLikeUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/ArticleCommentResponseLikeUserNotificationEvent.class.php
new file mode 100644
index 0000000000..03c3d393f2
--- /dev/null
+++ b/wcfsetup/install/files/lib/system/user/notification/event/ArticleCommentResponseLikeUserNotificationEvent.class.php
@@ -0,0 +1,136 @@
+
+ * @package WoltLabSuite\Core\System\User\Notification\Event
+ * @since 5.5
+ *
+ * @method LikeUserNotificationObject getUserNotificationObject()
+ */
+class ArticleCommentResponseLikeUserNotificationEvent extends AbstractSharedUserNotificationEvent implements
+ ITestableUserNotificationEvent
+{
+ use TTestableCommentResponseLikeUserNotificationEvent;
+ use TTestableArticleCommentUserNotificationEvent;
+ use TReactionUserNotificationEvent;
+
+ /**
+ * @inheritDoc
+ */
+ protected $stackable = true;
+
+ /**
+ * @inheritDoc
+ */
+ protected function prepare()
+ {
+ ViewableArticleContentRuntimeCache::getInstance()->cacheObjectID($this->additionalData['objectID']);
+ UserRuntimeCache::getInstance()->cacheObjectID($this->additionalData['commentUserID']);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getTitle()
+ {
+ $count = \count($this->getAuthors());
+ if ($count > 1) {
+ return $this->getLanguage()->getDynamicVariable(
+ 'wcf.user.notification.articleComment.response.like.title.stacked',
+ [
+ 'count' => $count,
+ 'timesTriggered' => $this->notification->timesTriggered,
+ ]
+ );
+ }
+
+ return $this->getLanguage()->get('wcf.user.notification.articleComment.response.like.title');
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getMessage()
+ {
+ $article = ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID']);
+ $authors = \array_values($this->getAuthors());
+ $count = \count($authors);
+ $commentUser = null;
+ if ($this->additionalData['commentUserID'] != WCF::getUser()->userID) {
+ $commentUser = UserRuntimeCache::getInstance()->getObject($this->additionalData['commentUserID']);
+ }
+
+ if ($count > 1) {
+ return $this->getLanguage()->getDynamicVariable(
+ 'wcf.user.notification.articleComment.response.like.message.stacked',
+ [
+ 'author' => $this->author,
+ 'authors' => $authors,
+ 'commentID' => $this->additionalData['commentID'],
+ 'commentUser' => $commentUser,
+ 'count' => $count,
+ 'others' => $count - 1,
+ 'article' => $article,
+ 'responseID' => $this->getUserNotificationObject()->objectID,
+ 'reactions' => $this->getReactionsForAuthors(),
+ ]
+ );
+ }
+
+ return $this->getLanguage()->getDynamicVariable('wcf.user.notification.articleComment.response.like.message', [
+ 'author' => $this->author,
+ 'commentID' => $this->additionalData['commentID'],
+ 'article' => $article,
+ 'responseID' => $this->getUserNotificationObject()->objectID,
+ 'reactions' => $this->getReactionsForAuthors(),
+ ]);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getEmailMessage($notificationType = 'instant')
+ {
+ // not supported
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getLink()
+ {
+ return ViewableArticleContentRuntimeCache::getInstance()->getObject($this->additionalData['objectID'])->getLink()
+ . '#comment' . $this->additionalData['commentID'] . '/response' . $this->getUserNotificationObject()->objectID;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getEventHash()
+ {
+ return \sha1($this->eventID . '-' . $this->getUserNotificationObject()->objectID);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function supportsEmailNotification()
+ {
+ return false;
+ }
+}
diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml
index cba516de56..f1c7916fae 100644
--- a/wcfsetup/install/lang/de.xml
+++ b/wcfsetup/install/lang/de.xml
@@ -5424,12 +5424,20 @@ Benachrichtigungen auf {PAGE_TITLE|phra
- {$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:
]]>
+
+
+ - {$author} hat auf {if LANGUAGE_USE_INFORMAL_VARIANT}deinen{else}Ihren{/if} Kommentar zum Artikel {$article->getTitle()} reagiert ({@$__wcf->getReactionHandler()->renderInlineList($reactions)}).]]>
+ - {$article->getTitle()} reagiert ({@$__wcf->getReactionHandler()->renderInlineList($reactions)}).]]>
- userID}{$author}{else}Ein Gast{/if} hat eine Antwort zu einem Kommentar in dem Artikel {$article->getTitle()} verfasst.]]>
- {$article->getTitle()} verfasst.]]>
- getAuthor()->userID || $guestTimesTriggered == 0)}hat eine Antwort{else}haben Antworten{/if} zu einem Kommentar in dem Artikel â{@$article->getTitle()}â [URL:{@$article->getLink()}#comments/comment{@$commentID}/response{@$responseID}] verfasst{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
- {@$authorList} {if $count == 1 && $guestTimesTriggered < 2 && (!$event->getAuthor()->userID || $guestTimesTriggered == 0)}hat eine Antwort{else}haben Antworten{/if} zu einem Kommentar in dem Artikel {$article->getTitle()} verfasst{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
+
+
+ - {$author} hat auf {if LANGUAGE_USE_INFORMAL_VARIANT}deine{else}Ihre{/if} Antwort auf einen Kommentar zum Artikel {$article->getTitle()} reagiert ({@$__wcf->getReactionHandler()->renderInlineList($reactions)}).]]>
+ - {$article->getTitle()} reagiert ({@$__wcf->getReactionHandler()->renderInlineList($reactions)}).]]>
- userID}{$author}{else}Ein Gast{/if} hat eine Antwort zum Kommentar von {$commentAuthor} zu {if LANGUAGE_USE_INFORMAL_VARIANT}deinem{else}Ihrem{/if} Artikel {$article->getTitle()} verfasst.]]>
@@ -5444,6 +5452,8 @@ Benachrichtigungen auf {PAGE_TITLE|phra
+
+
- {$author} hat sich registriert.]]>
diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml
index 5856e6b897..3c83629346 100644
--- a/wcfsetup/install/lang/en.xml
+++ b/wcfsetup/install/lang/en.xml
@@ -5425,12 +5425,20 @@ your notifications on {PAGE_TITLE|phras
- {$article->getTitle()}.]]>
- getTitle()}â [URL:{@$article->getLink()}#comment{@$commentID}]{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
- {@$authorList} commented on the article {$article->getTitle()}:]]>
+
+
+ - {$author} reacted to your comment on the article {$article->getTitle()} ({@$__wcf->getReactionHandler()->renderInlineList($reactions)}).]]>
+ - {$article->getTitle()} ({@$__wcf->getReactionHandler()->renderInlineList($reactions)}).]]>
- userID}{$author}{else}A guest{/if} replied to a comment on the article {$article->getTitle()}.]]>
- {$article->getTitle()}.]]>
- getTitle()}â [URL:{@$article->getLink()}#comments/comment{@$commentID}/response{@$responseID}]{if $count == 1 && !$guestTimesTriggered}:{else}.{/if}]]>
- {@$authorList} replied to a comment on the article {$article->getTitle()}:]]>
+
+
+ - {$author} reacted to your reply to a comment on the article {$article->getTitle()} ({@$__wcf->getReactionHandler()->renderInlineList($reactions)}).]]>
+ - {$article->getTitle()} ({@$__wcf->getReactionHandler()->renderInlineList($reactions)}).]]>
- userID}{$author}{else}A guest{/if} replied to a comment by {$commentAuthor} on your article {$article->getTitle()}.]]>
@@ -5445,6 +5453,8 @@ your notifications on {PAGE_TITLE|phras
+
+