mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-27 10:49:45 +08:00
Notifications: Started activity->notification core framework
This commit is contained in:
parent
1c922be4c7
commit
45e75edf05
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace BookStack\Activity\Notifications\Handlers;
|
||||
|
||||
use BookStack\Activity\Models\Loggable;
|
||||
|
||||
class CommentCreationNotificationHandler implements NotificationHandler
|
||||
{
|
||||
public function handle(string $activityType, Loggable|string $detail): void
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
13
app/Activity/Notifications/Handlers/NotificationHandler.php
Normal file
13
app/Activity/Notifications/Handlers/NotificationHandler.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace BookStack\Activity\Notifications\Handlers;
|
||||
|
||||
use BookStack\Activity\Models\Loggable;
|
||||
|
||||
interface NotificationHandler
|
||||
{
|
||||
/**
|
||||
* Run this handler.
|
||||
*/
|
||||
public function handle(string $activityType, string|Loggable $detail): void;
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace BookStack\Activity\Notifications\Handlers;
|
||||
|
||||
use BookStack\Activity\Models\Loggable;
|
||||
|
||||
class PageCreationNotificationHandler implements NotificationHandler
|
||||
{
|
||||
public function handle(string $activityType, Loggable|string $detail): void
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace BookStack\Activity\Notifications\Handlers;
|
||||
|
||||
use BookStack\Activity\Models\Loggable;
|
||||
|
||||
class PageUpdateNotificationHandler implements NotificationHandler
|
||||
{
|
||||
public function handle(string $activityType, Loggable|string $detail): void
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ use BookStack\Activity\DispatchWebhookJob;
|
|||
use BookStack\Activity\Models\Activity;
|
||||
use BookStack\Activity\Models\Loggable;
|
||||
use BookStack\Activity\Models\Webhook;
|
||||
use BookStack\App\Model;
|
||||
use BookStack\Activity\Notifications\NotificationManager;
|
||||
use BookStack\Entities\Models\Entity;
|
||||
use BookStack\Facades\Theme;
|
||||
use BookStack\Theming\ThemeEvents;
|
||||
|
@ -15,10 +15,16 @@ use Illuminate\Support\Facades\Log;
|
|||
|
||||
class ActivityLogger
|
||||
{
|
||||
public function __construct(
|
||||
protected NotificationManager $notifications
|
||||
) {
|
||||
$this->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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user