// fire notification event
if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.response.notification')) {
- $notificationObjectType = UserNotificationHandler::getInstance()->getObjectTypeProcessor($objectType->objectType.'.notification');
+ $notificationObjectType = UserNotificationHandler::getInstance()->getObjectTypeProcessor($objectType->objectType.'.response.notification');
- $userID = $notificationObjectType->getOwnerID($this->comment->commentID);
-
$notificationObject = new CommentResponseUserNotificationObject($this->createdResponse);
- if ($this->comment->userID != WCF::getUser()->userID) {
- UserNotificationHandler::getInstance()->fireEvent('commentResponse', $objectType->objectType.'.response.notification', $notificationObject, array($this->comment->userID), array(
- 'commentID' => $this->comment->commentID,
- 'objectID' => $this->comment->objectID,
- 'objectUserID' => $userID,
- 'userID' => $this->comment->userID
- ));
- }
- // notify the container owner
- if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.notification')) {
- if ($userID != $this->comment->userID && $userID != WCF::getUser()->userID) {
- UserNotificationHandler::getInstance()->fireEvent('commentResponseOwner', $objectType->objectType.'.response.notification', $notificationObject, array($userID), array(
- 'commentID' => $this->comment->commentID,
- 'objectID' => $this->comment->objectID,
- 'objectUserID' => $userID,
- 'userID' => $this->comment->userID
- ));
+ if ($notificationObjectType instanceof IMultiRecipientCommentUserNotificationObjectType) {
+ $recipientIDs = $notificationObjectType->getRecipientIDs($this->comment);
+
+ // make sure that the active user gets no notification
+ $recipientIDs = array_diff($recipientIDs, [WCF::getUser()->userID]);
+
+ if (!empty($recipientIDs)) {
+ UserNotificationHandler::getInstance()->fireEvent(
+ 'commentResponse',
+ $objectType->objectType . '.response.notification',
+ $notificationObject,
+ $recipientIDs,
+ [
+ 'commentID' => $this->comment->commentID,
+ 'objectID' => $this->comment->objectID,
+ 'userID' => $this->comment->userID
+ ]
+ );
+ }
+ }
+ else {
+ /** @var ICommentUserNotificationObjectType $notificationObjectType */
+
+ $userID = $notificationObjectType->getOwnerID($this->comment->commentID);
+
+ if ($this->comment->userID != WCF::getUser()->userID) {
+ UserNotificationHandler::getInstance()->fireEvent(
+ 'commentResponse',
+ $objectType->objectType . '.response.notification',
+ $notificationObject,
+ [$this->comment->userID],
+ [
+ 'commentID' => $this->comment->commentID,
+ 'objectID' => $this->comment->objectID,
+ 'objectUserID' => $userID,
+ 'userID' => $this->comment->userID
+ ]
+ );
+ }
+
+ // notify the container owner
+ if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.notification')) {
+ if ($userID != $this->comment->userID && $userID != WCF::getUser()->userID) {
+ UserNotificationHandler::getInstance()->fireEvent(
+ 'commentResponseOwner',
+ $objectType->objectType . '.response.notification',
+ $notificationObject,
+ [$userID], [
+ 'commentID' => $this->comment->commentID,
+ 'objectID' => $this->comment->objectID,
+ 'objectUserID' => $userID,
+ 'userID' => $this->comment->userID
+ ]
+ );
+ }
}
}
}