3 namespace BookStack\Activity\Notifications\Handlers;
5 use BookStack\Activity\Models\Loggable;
6 use BookStack\Activity\Models\Watch;
7 use BookStack\Activity\Tools\EntityWatchers;
8 use BookStack\Activity\WatchLevels;
9 use BookStack\Users\Models\User;
11 class PageCreationNotificationHandler implements NotificationHandler
13 public function handle(string $activityType, Loggable|string $detail, User $user): void
17 // No user-level preferences to care about here.
18 // Possible Scenarios:
19 // ✅ User watching parent chapter
20 // ✅ User watching parent book
21 // ❌ User ignoring parent book
22 // ❌ User ignoring parent chapter
23 // ❌ User watching parent book, ignoring chapter
24 // ✅ User watching parent book, watching chapter
25 // ❌ User ignoring parent book, ignoring chapter
26 // ✅ User ignoring parent book, watching chapter
28 // Get all relevant watchers
29 $watchers = new EntityWatchers($detail, WatchLevels::NEW);
31 // TODO - need to check entity visibility and receive-notifications permissions.
32 // Maybe abstract this to a generic late-stage filter?