3 namespace BookStack\Activity\Notifications\Messages;
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;
12 class CommentCreationNotification extends BaseActivityNotification
14 public function toMail(User $notifiable): MailMessage
16 /** @var Comment $comment */
17 $comment = $this->detail;
18 /** @var Page $page */
19 $page = $comment->entity;
21 $locale = $notifiable->getLocale();
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),
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));