Check notification support before send notifications for reactions
authorJoshua Rüsweg <josh@bastelstu.be>
Wed, 27 Jun 2018 18:48:49 +0000 (20:48 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Wed, 27 Jun 2018 18:48:49 +0000 (20:48 +0200)
See #2508

wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php

index c68c2ae0ea68e782db86bc3965e5fce7d9aa8b33..90e92901ed6ea2e8e133e05491fb516dae19e563 100644 (file)
@@ -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']);