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