]> BookStack Code Mirror - bookstack/blob - app/Activity/Notifications/Messages/CommentCreationNotification.php
Notifications: Added logic and classes for remaining notification types
[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\LinkedMailMessageLine;
7 use BookStack\Entities\Models\Page;
8 use Illuminate\Notifications\Messages\MailMessage;
9
10 class CommentCreationNotification extends BaseActivityNotification
11 {
12     public function toMail(mixed $notifiable): MailMessage
13     {
14         /** @var Comment $comment */
15         $comment = $this->detail;
16         /** @var Page $page */
17         $page = $comment->entity;
18
19         return (new MailMessage())
20             ->subject("New Comment on Page: " . $page->getShortName())
21             ->line("A user has commented on a page in " . setting('app-name') . ':')
22             ->line("Page Name: " . $page->name)
23             ->line("Commenter: " . $this->user->name)
24             ->line("Comment: " . strip_tags($comment->html))
25             ->action('View Comment', $page->getUrl('#comment' . $comment->local_id))
26             ->line(new LinkedMailMessageLine(
27                 url('/preferences/notifications'),
28                 'This notification was sent to you because :link cover this type of activity for this item.',
29                 'your notification preferences',
30             ));
31     }
32 }