1
0
mirror of https://github.com/flarum/core.git synced 2025-10-18 10:16:09 +02:00

More powerful/extensible notifications

- Notifications can be delivered in multiple ways (alert, email)
- Different notification types can implement interfaces to allow
themselves to be delivered in these various ways
- User preferences for each notification type/method combination are
automatically registered
This commit is contained in:
Toby Zerner
2015-03-28 15:43:31 +10:30
parent 49c3fa09e6
commit bc9be30a02
15 changed files with 292 additions and 43 deletions

View File

@@ -1,11 +1,17 @@
<?php namespace Flarum\Core\Handlers\Events;
use Flarum\Core\Events\DiscussionWasRenamed;
use Flarum\Core\Models\Notification;
use Flarum\Core\Models\DiscussionRenamedPost;
use Flarum\Core\Notifications\Types\DiscussionRenamedNotification;
use Flarum\Core\Notifications\Notifier;
class DiscussionRenamedNotifier
{
public function __construct(Notifier $notifier)
{
$this->notifier = $notifier;
}
/**
* Register the listeners for the subscriber.
*
@@ -44,17 +50,13 @@ class DiscussionRenamedNotifier
protected function sendNotification(DiscussionWasRenamed $event, DiscussionRenamedPost $post)
{
$notification = Notification::notify(
$event->discussion->start_user_id,
'renamed',
$event->user->id,
$event->discussion->id,
['number' => $post->number, 'oldTitle' => $event->oldTitle]
$notification = new DiscussionRenamedNotification(
$event->discussion->startUser,
$event->user,
$post,
$event->oldTitle
);
$notification->save();
return $notification;
$this->notifier->send($notification);
}
}