Add only reaction activity event if the object support these
authorJoshua Rüsweg <josh@bastelstu.be>
Wed, 25 Jul 2018 13:10:40 +0000 (15:10 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Wed, 25 Jul 2018 13:10:40 +0000 (15:10 +0200)
See #2508

com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/system/reaction/ReactionHandler.class.php

index 970252a156f888f7d64b87fa0e9c96c35236ff30..4b91e84ed2ed30b038243230dc51c0c4f5a42a1c 100644 (file)
@@ -49,6 +49,7 @@
                        <name>com.woltlab.wcf.likeableArticle.recentActivityEvent</name>
                        <definitionname>com.woltlab.wcf.user.recentActivityEvent</definitionname>
                        <classname>wcf\system\user\activity\event\LikeableArticleUserActivityEvent</classname>
+                       <supportReactions>1</supportReactions>
                </type>
                <type>
                        <name>com.woltlab.wcf.articleComment.recentActivityEvent</name>
index 4fd3df72a14159f4136f4e37fa78a25ffeeee17c..9aaa09e0c26fe68d5b50be65e643c891f5b75f03 100644 (file)
@@ -304,13 +304,15 @@ class ReactionHandler extends SingletonFactory {
                        
                        // update recent activity
                        if (UserActivityEventHandler::getInstance()->getObjectTypeID($likeable->getObjectType()->objectType.'.recentActivityEvent')) {
-                               if ($like->likeID) {
-                                       UserActivityEventHandler::getInstance()->removeEvent($likeable->getObjectType()->objectType.'.recentActivityEvent', $likeable->getObjectID(), $user->userID);
-                               }
+                               $objectType = ObjectTypeCache::getInstance()->getObjectTypeByName('com.woltlab.wcf.user.recentActivityEvent', $likeable->getObjectType()->objectType.'.recentActivityEvent');
                                
-                               UserActivityEventHandler::getInstance()->fireEvent($likeable->getObjectType()->objectType.'.recentActivityEvent', $likeable->getObjectID(), $likeable->getLanguageID(), $user->userID, TIME_NOW, [
-                                       'reactionType' => $reaction
-                               ]);
+                               if ($objectType->supportReactions) {
+                                       if ($like->likeID) {
+                                               UserActivityEventHandler::getInstance()->removeEvent($likeable->getObjectType()->objectType . '.recentActivityEvent', $likeable->getObjectID(), $user->userID);
+                                       }
+                                       
+                                       UserActivityEventHandler::getInstance()->fireEvent($likeable->getObjectType()->objectType . '.recentActivityEvent', $likeable->getObjectID(), $likeable->getLanguageID(), $user->userID, TIME_NOW, ['reactionType' => $reaction]);
+                               }
                        }
                        
                        WCF::getDB()->commitTransaction();