From 45e75edf0544217e1a46f5628037770a6713b23b Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Wed, 19 Jul 2023 11:03:05 +0100 Subject: [PATCH] Notifications: Started activity->notification core framework --- .../Handlers/CommentCreationNotificationHandler.php | 13 +++++++++++++ .../Notifications/Handlers/NotificationHandler.php | 13 +++++++++++++ .../Handlers/PageCreationNotificationHandler.php | 13 +++++++++++++ .../Handlers/PageUpdateNotificationHandler.php | 13 +++++++++++++ app/Activity/Tools/ActivityLogger.php | 11 +++++++++-- 5 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 app/Activity/Notifications/Handlers/CommentCreationNotificationHandler.php create mode 100644 app/Activity/Notifications/Handlers/NotificationHandler.php create mode 100644 app/Activity/Notifications/Handlers/PageCreationNotificationHandler.php create mode 100644 app/Activity/Notifications/Handlers/PageUpdateNotificationHandler.php diff --git a/app/Activity/Notifications/Handlers/CommentCreationNotificationHandler.php b/app/Activity/Notifications/Handlers/CommentCreationNotificationHandler.php new file mode 100644 index 000000000..5f2e1c770 --- /dev/null +++ b/app/Activity/Notifications/Handlers/CommentCreationNotificationHandler.php @@ -0,0 +1,13 @@ +notifications->loadDefaultHandlers(); + } + /** * Add a generic activity event to the database. */ - public function add(string $type, $detail = '') + public function add(string $type, string|Loggable $detail = ''): void { $detailToStore = ($detail instanceof Loggable) ? $detail->logDescriptor() : $detail; @@ -34,6 +40,7 @@ class ActivityLogger $this->setNotification($type); $this->dispatchWebhooks($type, $detail); + $this->notifications->handle($type, $detail); Theme::dispatch(ThemeEvents::ACTIVITY_LOGGED, $type, $detail); }