if (!empty($groupCommentIDs)) {
$likeObjectIDs = array();
+ $notificationObjectTypes = array();
foreach ($groupCommentIDs as $objectTypeID => $objectIDs) {
// remove activity events
$objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.notification')) {
UserNotificationHandler::getInstance()->deleteNotifications('comment', $objectType->objectType.'.notification', array(), $objectIDs);
}
+
+ if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.like.notification')) {
+ $notificationObjectTypes[] = $objectType->objectType.'.like.notification';
+ }
}
// remove likes
- LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment', $likeObjectIDs);
+ LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment', $likeObjectIDs, $notificationObjectTypes);
}
// delete responses
}
$likeObjectIDs = array();
+ $notificationObjectTypes = array();
foreach ($responseIDs as $objectTypeID => $objectIDs) {
// remove activity events
$objectType = ObjectTypeCache::getInstance()->getObjectType($objectTypeID);
}
$likeObjectIDs = array_merge($likeObjectIDs, $objectIDs);
+
+ if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType->objectType.'.response.like.notification')) {
+ $notificationObjectTypes[] = $objectType->objectType.'.response.like.notification';
+ }
}
// remove likes
if (!empty($likeObjectIDs)) {
- LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment.response', $likeObjectIDs);
+ LikeHandler::getInstance()->removeLikes('com.woltlab.wcf.comment.response', $likeObjectIDs, $notificationObjectTypes);
}
return $count;
use wcf\system\database\DatabaseException;
use wcf\system\user\activity\event\UserActivityEventHandler;
use wcf\system\user\activity\point\UserActivityPointHandler;
+use wcf\system\user\notification\UserNotificationHandler;
use wcf\system\SingletonFactory;
use wcf\system\WCF;
/**
* Removes all likes for given objects.
*
- * @param string $objectType
- * @param array<integer> $objectIDs
+ * @param string $objectType
+ * @param array<integer> $objectIDs
+ * @param array<string> $notificationObjectTypes
*/
- public function removeLikes($objectType, array $objectIDs) {
+ public function removeLikes($objectType, array $objectIDs, array $notificationObjectTypes = array()) {
$objectTypeObj = $this->getObjectType($objectType);
// get like objects
$likeData[$like->likeID] = $like->userID;
}
+ // delete like notifications
+ if (!empty($notificationObjectTypes)) {
+ foreach ($notificationObjectTypes as $notificationObjectType) {
+ UserNotificationHandler::getInstance()->removeNotifications($notificationObjectType, $likeList->getObjectIDs());
+ }
+ }
+ else if (UserNotificationHandler::getInstance()->getObjectTypeID($objectType.'.notification')) {
+ UserNotificationHandler::getInstance()->removeNotifications($objectType.'.notification', $likeList->getObjectIDs());
+ }
+
// revoke activity points
UserActivityPointHandler::getInstance()->removeEvents('com.woltlab.wcf.like.activityPointEvent.receivedLikes', $likeData);