]> BookStack Code Mirror - bookstack/blob - app/Activity/Notifications/Messages/CommentCreationNotification.php
Opensearch: Fixed XML declaration when php short tags enabled
[bookstack] / app / Activity / Notifications / Messages / CommentCreationNotification.php
1 <?php
2
3 namespace BookStack\Activity\Notifications\Messages;
4
5 use BookStack\Activity\Models\Comment;
6 use BookStack\Activity\Notifications\MessageParts\EntityLinkMessageLine;
7 use BookStack\Activity\Notifications\MessageParts\ListMessageLine;
8 use BookStack\Entities\Models\Page;
9 use BookStack\Users\Models\User;
10 use Illuminate\Notifications\Messages\MailMessage;
11
12 class CommentCreationNotification extends BaseActivityNotification
13 {
14     public function toMail(User $notifiable): MailMessage
15     {
16         /** @var Comment $comment */
17         $comment = $this->detail;
18         /** @var Page $page */
19         $page = $comment->entity;
20
21         $locale = $notifiable->getLocale();
22
23         $listLines = array_filter([
24             $locale->trans('notifications.detail_page_name') => new EntityLinkMessageLine($page),
25             $locale->trans('notifications.detail_page_path') => $this->buildPagePathLine($page, $notifiable),
26             $locale->trans('notifications.detail_commenter') => $this->user->name,
27             $locale->trans('notifications.detail_comment') => strip_tags($comment->html),
28         ]);
29
30         return $this->newMailMessage($locale)
31             ->subject($locale->trans('notifications.new_comment_subject', ['pageName' => $page->getShortName()]))
32             ->line($locale->trans('notifications.new_comment_intro', ['appName' => setting('app-name')]))
33             ->line(new ListMessageLine($listLines))
34             ->action($locale->trans('notifications.action_view_comment'), $page->getUrl('#comment' . $comment->local_id))
35             ->line($this->buildReasonFooterLine($locale));
36     }
37 }