1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-07 23:03:00 +03:00

Notifications: Started core user notification logic

Put together an initial notification.
Started logic to query and identify watchers.
This commit is contained in:
Dan Brown
2023-08-04 12:27:29 +01:00
parent 9d149e4d36
commit 9779c1a357
13 changed files with 258 additions and 42 deletions

View File

@@ -3,11 +3,32 @@
namespace BookStack\Activity\Notifications\Handlers;
use BookStack\Activity\Models\Loggable;
use BookStack\Activity\Models\Watch;
use BookStack\Activity\Tools\EntityWatchers;
use BookStack\Activity\WatchLevels;
use BookStack\Users\Models\User;
class PageCreationNotificationHandler implements NotificationHandler
{
public function handle(string $activityType, Loggable|string $detail): void
public function handle(string $activityType, Loggable|string $detail, User $user): void
{
// TODO
// No user-level preferences to care about here.
// Possible Scenarios:
// ✅ User watching parent chapter
// ✅ User watching parent book
// ❌ User ignoring parent book
// ❌ User ignoring parent chapter
// ❌ User watching parent book, ignoring chapter
// ✅ User watching parent book, watching chapter
// ❌ User ignoring parent book, ignoring chapter
// ✅ User ignoring parent book, watching chapter
// Get all relevant watchers
$watchers = new EntityWatchers($detail, WatchLevels::NEW);
// TODO - need to check entity visibility and receive-notifications permissions.
// Maybe abstract this to a generic late-stage filter?
}
}