1
0
mirror of https://github.com/flarum/core.git synced 2025-07-28 12:10:51 +02:00

Email notifications. Too easy!

This commit is contained in:
Toby Zerner
2015-05-19 11:02:02 +09:30
parent 4080a76a99
commit 978ecd369d
5 changed files with 53 additions and 7 deletions

View File

@@ -13,6 +13,8 @@ class MentionsServiceProvider extends ServiceProvider
{
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../views', 'mentions');
$this->extend(
new EventSubscribers([
'Flarum\Mentions\Handlers\PostMentionsMetadataUpdater',

View File

@@ -4,14 +4,17 @@ use Flarum\Core\Models\User;
use Flarum\Core\Models\Post;
use Flarum\Core\Notifications\Types\Notification;
use Flarum\Core\Notifications\Types\AlertableNotification;
use Flarum\Core\Notifications\Types\EmailableNotification;
class PostMentionedNotification extends Notification implements AlertableNotification
class PostMentionedNotification extends Notification implements
AlertableNotification,
EmailableNotification
{
protected $post;
public $post;
protected $sender;
public $sender;
protected $reply;
public $reply;
public function __construct(Post $post, User $sender, Post $reply)
{
@@ -35,6 +38,16 @@ class PostMentionedNotification extends Notification implements AlertableNotific
return ['replyNumber' => $this->reply->number];
}
public function getEmailView()
{
return ['text' => 'mentions::emails.postMentioned'];
}
public function getEmailSubject()
{
return "{$this->sender->username} replied to your post in {$this->post->discussion->title}";
}
public static function getType()
{
return 'postMentioned';

View File

@@ -4,12 +4,15 @@ use Flarum\Core\Models\User;
use Flarum\Core\Models\Post;
use Flarum\Core\Notifications\Types\Notification;
use Flarum\Core\Notifications\Types\AlertableNotification;
use Flarum\Core\Notifications\Types\EmailableNotification;
class UserMentionedNotification extends Notification implements AlertableNotification
class UserMentionedNotification extends Notification implements
AlertableNotification,
EmailableNotification
{
protected $sender;
public $sender;
protected $post;
public $post;
public function __construct(User $sender, Post $post)
{
@@ -32,6 +35,16 @@ class UserMentionedNotification extends Notification implements AlertableNotific
return null;
}
public function getEmailView()
{
return ['text' => 'mentions::emails.userMentioned'];
}
public function getEmailSubject()
{
return "{$this->sender->username} mentioned you in {$this->post->discussion->title}";
}
public static function getType()
{
return 'userMentioned';

View File

@@ -0,0 +1,9 @@
Hey {{ $user->username }}!
{{ $notification->sender->username }} replied to your post (#{{ $notification->post->number }}) in {{ $notification->post->discussion->title }}.
{{ \Flarum\Core::config('base_url') }}/d/{{ $notification->reply->discussion_id }}/-/{{ $notification->reply->number }}
---
{{{ $notification->reply->contentPlain }}}

View File

@@ -0,0 +1,9 @@
Hey {{ $user->username }}!
{{ $notification->sender->username }} mentioned you in a post in {{ $notification->post->discussion->title }}.
{{ \Flarum\Core::config('base_url') }}/d/{{ $notification->post->discussion_id }}/-/{{ $notification->post->number }}
---
{{{ $notification->post->contentPlain }}}