3 namespace BookStack\Activity\Notifications\Handlers;
5 use BookStack\Activity\Models\Loggable;
6 use BookStack\Activity\Notifications\Messages\PageCreationNotification;
7 use BookStack\Activity\Tools\EntityWatchers;
8 use BookStack\Activity\WatchLevels;
9 use BookStack\Entities\Models\Page;
10 use BookStack\Users\Models\User;
12 class PageCreationNotificationHandler extends BaseNotificationHandler
14 public function handle(string $activityType, Loggable|string $detail, User $user): void
16 if (!($detail instanceof Page)) {
17 throw new \InvalidArgumentException("Detail for page create notifications must be a page");
20 $watchers = new EntityWatchers($detail, WatchLevels::NEW);
21 $this->sendNotificationToUserIds(PageCreationNotification::class, $watchers->getWatcherUserIds(), $user, $detail);