mirror of
https://github.com/flarum/core.git
synced 2025-07-28 20:20:34 +02:00
Email notifications. Too easy!
This commit is contained in:
@@ -13,6 +13,8 @@ class MentionsServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
$this->loadViewsFrom(__DIR__.'/../views', 'mentions');
|
||||
|
||||
$this->extend(
|
||||
new EventSubscribers([
|
||||
'Flarum\Mentions\Handlers\PostMentionsMetadataUpdater',
|
||||
|
@@ -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';
|
||||
|
@@ -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';
|
||||
|
9
extensions/mentions/views/emails/postMentioned.blade.php
Normal file
9
extensions/mentions/views/emails/postMentioned.blade.php
Normal 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 }}}
|
9
extensions/mentions/views/emails/userMentioned.blade.php
Normal file
9
extensions/mentions/views/emails/userMentioned.blade.php
Normal 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 }}}
|
Reference in New Issue
Block a user