diff --git a/extensions/mentions/src/MentionsServiceProvider.php b/extensions/mentions/src/MentionsServiceProvider.php index dfca81072..cd9b5ce8f 100644 --- a/extensions/mentions/src/MentionsServiceProvider.php +++ b/extensions/mentions/src/MentionsServiceProvider.php @@ -13,6 +13,8 @@ class MentionsServiceProvider extends ServiceProvider { public function boot() { + $this->loadViewsFrom(__DIR__.'/../views', 'mentions'); + $this->extend( new EventSubscribers([ 'Flarum\Mentions\Handlers\PostMentionsMetadataUpdater', diff --git a/extensions/mentions/src/PostMentionedNotification.php b/extensions/mentions/src/PostMentionedNotification.php index 685070f56..1df460183 100644 --- a/extensions/mentions/src/PostMentionedNotification.php +++ b/extensions/mentions/src/PostMentionedNotification.php @@ -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'; diff --git a/extensions/mentions/src/UserMentionedNotification.php b/extensions/mentions/src/UserMentionedNotification.php index f4597cad9..08c229239 100644 --- a/extensions/mentions/src/UserMentionedNotification.php +++ b/extensions/mentions/src/UserMentionedNotification.php @@ -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'; diff --git a/extensions/mentions/views/emails/postMentioned.blade.php b/extensions/mentions/views/emails/postMentioned.blade.php new file mode 100644 index 000000000..999b7c7c5 --- /dev/null +++ b/extensions/mentions/views/emails/postMentioned.blade.php @@ -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 }}} diff --git a/extensions/mentions/views/emails/userMentioned.blade.php b/extensions/mentions/views/emails/userMentioned.blade.php new file mode 100644 index 000000000..e8ed2697d --- /dev/null +++ b/extensions/mentions/views/emails/userMentioned.blade.php @@ -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 }}}