From 42ce3082bd1004181d00691374abdebc061a11ed Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joshua=20R=C3=BCsweg?= Date: Wed, 27 Jun 2018 20:48:49 +0200 Subject: [PATCH] Check notification support before send notifications for reactions See #2508 --- .../lib/system/reaction/ReactionHandler.class.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php index c68c2ae0ea..90e92901ed 100644 --- a/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php +++ b/wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php @@ -9,6 +9,7 @@ use wcf\data\like\Like; use wcf\data\like\LikeEditor; use wcf\data\object\type\ObjectType; use wcf\data\object\type\ObjectTypeCache; +use wcf\data\reaction\object\IReactionObject; use wcf\data\reaction\type\ReactionType; use wcf\data\reaction\type\ReactionTypeCache; use wcf\data\user\User; @@ -267,9 +268,6 @@ class ReactionHandler extends SingletonFactory { if ($reaction->isPositive() && $likeable->getUserID()) { UserActivityPointHandler::getInstance()->fireEvent('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $like->likeID, $likeable->getUserID()); - - // @TODO send notification - //$likeable->sendNotification($like); } } else { @@ -286,13 +284,17 @@ class ReactionHandler extends SingletonFactory { } else if (!$like->getReactionType()->isPositive() && $reaction->isPositive()) { UserActivityPointHandler::getInstance()->fireEvent('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $like->likeID, $likeable->getUserID()); - - // @TODO send notification - //$likeable->sendNotification($like); } } } + // This interface should help to determine whether the plugin has been adapted to the API 3.2. + // If a LikeableObject does not implement this interface, no notification will be sent, because + // we assume, that the plugin is adapted to the new API. + if ($likeable instanceof IReactionObject) { + $likeable->sendNotification($like); + } + // update object's like counter $likeable->updateLikeCounter($likeObjectData['cumulativeLikes']); -- 2.20.1