2023-08-05 21:19:23 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace BookStack\Activity\Notifications\Messages;
|
|
|
|
|
|
|
|
use BookStack\Activity\Models\Comment;
|
2023-11-14 18:31:44 +08:00
|
|
|
use BookStack\Activity\Notifications\MessageParts\EntityLinkMessageLine;
|
2023-08-15 21:39:39 +08:00
|
|
|
use BookStack\Activity\Notifications\MessageParts\ListMessageLine;
|
2023-08-05 21:19:23 +08:00
|
|
|
use BookStack\Entities\Models\Page;
|
2023-09-02 22:11:42 +08:00
|
|
|
use BookStack\Users\Models\User;
|
2023-08-05 21:19:23 +08:00
|
|
|
use Illuminate\Notifications\Messages\MailMessage;
|
|
|
|
|
|
|
|
class CommentCreationNotification extends BaseActivityNotification
|
|
|
|
{
|
2023-09-02 22:11:42 +08:00
|
|
|
public function toMail(User $notifiable): MailMessage
|
2023-08-05 21:19:23 +08:00
|
|
|
{
|
|
|
|
/** @var Comment $comment */
|
|
|
|
$comment = $this->detail;
|
|
|
|
/** @var Page $page */
|
|
|
|
$page = $comment->entity;
|
|
|
|
|
2023-09-17 23:20:21 +08:00
|
|
|
$locale = $notifiable->getLocale();
|
2023-09-02 22:11:42 +08:00
|
|
|
|
2023-11-14 18:31:44 +08:00
|
|
|
$listLines = array_filter([
|
|
|
|
$locale->trans('notifications.detail_page_name') => new EntityLinkMessageLine($page),
|
|
|
|
$locale->trans('notifications.detail_page_path') => $this->buildPagePathLine($page, $notifiable),
|
|
|
|
$locale->trans('notifications.detail_commenter') => $this->user->name,
|
|
|
|
$locale->trans('notifications.detail_comment') => strip_tags($comment->html),
|
|
|
|
]);
|
|
|
|
|
2023-09-17 23:20:21 +08:00
|
|
|
return $this->newMailMessage($locale)
|
|
|
|
->subject($locale->trans('notifications.new_comment_subject', ['pageName' => $page->getShortName()]))
|
|
|
|
->line($locale->trans('notifications.new_comment_intro', ['appName' => setting('app-name')]))
|
2023-11-14 18:31:44 +08:00
|
|
|
->line(new ListMessageLine($listLines))
|
2023-09-17 23:20:21 +08:00
|
|
|
->action($locale->trans('notifications.action_view_comment'), $page->getUrl('#comment' . $comment->local_id))
|
|
|
|
->line($this->buildReasonFooterLine($locale));
|
2023-08-05 21:19:23 +08:00
|
|
|
}
|
|
|
|
}
|