public function onGetComment(CommentEvent $event)
{
$item = $this->itemService->getByOpenItemId($event->getId());
$recipient = $this->userService->getById($item->user_id);
$sender = $this->userService->getById($event->getUserId());
if ($this->userRoleService->isRetire($recipient->id)) {
return false;
}
if ($this->areUsersSame($recipient, $sender)) {
return false;
} elseif (!$this->notificationIsEnabled('comment', $recipient->id)) {
return false;
}
$data = $this->getDataForMail($item, $recipient, $sender);
$data['comment'] = $event->getComment();
$this->mail->send('emails.action.comment', $data, function ($m) use($recipient, $sender) {
$m->to($recipient->email)->subject($sender->username . 'さんからコメントがつきました - Owl');
});
}