X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/ecab2c8e42ae11485bb3c0fcce1a51df1bc6b118..refs/pull/5725/head:/app/Activity/Notifications/Handlers/CommentCreationNotificationHandler.php diff --git a/app/Activity/Notifications/Handlers/CommentCreationNotificationHandler.php b/app/Activity/Notifications/Handlers/CommentCreationNotificationHandler.php index 27d61307a..bc12c8566 100644 --- a/app/Activity/Notifications/Handlers/CommentCreationNotificationHandler.php +++ b/app/Activity/Notifications/Handlers/CommentCreationNotificationHandler.php @@ -2,32 +2,35 @@ namespace BookStack\Activity\Notifications\Handlers; +use BookStack\Activity\Models\Activity; use BookStack\Activity\Models\Comment; use BookStack\Activity\Models\Loggable; use BookStack\Activity\Notifications\Messages\CommentCreationNotification; use BookStack\Activity\Tools\EntityWatchers; use BookStack\Activity\WatchLevels; +use BookStack\Entities\Models\Page; use BookStack\Settings\UserNotificationPreferences; use BookStack\Users\Models\User; class CommentCreationNotificationHandler extends BaseNotificationHandler { - public function handle(string $activityType, Loggable|string $detail, User $user): void + public function handle(Activity $activity, Loggable|string $detail, User $user): void { if (!($detail instanceof Comment)) { throw new \InvalidArgumentException("Detail for comment creation notifications must be a comment"); } // Main watchers + /** @var Page $page */ $page = $detail->entity; $watchers = new EntityWatchers($page, WatchLevels::COMMENTS); $watcherIds = $watchers->getWatcherUserIds(); // Page owner if user preferences allow - if (!$watchers->isUserIgnoring($detail->owned_by) && $detail->ownedBy) { - $userNotificationPrefs = new UserNotificationPreferences($detail->ownedBy); + if (!$watchers->isUserIgnoring($page->owned_by) && $page->ownedBy) { + $userNotificationPrefs = new UserNotificationPreferences($page->ownedBy); if ($userNotificationPrefs->notifyOnOwnPageComments()) { - $watcherIds[] = $detail->owned_by; + $watcherIds[] = $page->owned_by; } } @@ -40,6 +43,6 @@ class CommentCreationNotificationHandler extends BaseNotificationHandler } } - $this->sendNotificationToUserIds(CommentCreationNotification::class, $watcherIds, $user, $page); + $this->sendNotificationToUserIds(CommentCreationNotification::class, $watcherIds, $user, $detail, $page); } }