]> BookStack Code Mirror - bookstack/blob - app/Activity/Notifications/Handlers/PageCreationNotificationHandler.php
Notifications: Started core user notification logic
[bookstack] / app / Activity / Notifications / Handlers / PageCreationNotificationHandler.php
1 <?php
2
3 namespace BookStack\Activity\Notifications\Handlers;
4
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;
10
11 class PageCreationNotificationHandler implements NotificationHandler
12 {
13     public function handle(string $activityType, Loggable|string $detail, User $user): void
14     {
15         // TODO
16
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
27
28         // Get all relevant watchers
29         $watchers = new EntityWatchers($detail, WatchLevels::NEW);
30
31         // TODO - need to check entity visibility and receive-notifications permissions.
32         //   Maybe abstract this to a generic late-stage filter?
33     }
34 }