• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/integration/im/notification/usecase/commentcreated.php
  • Класс: BitrixTasksIntegrationIMNotificationUseCaseCommentCreated
  • Вызов: CommentCreated::getNotification
public function getNotification(Message $message): ?Notification
{
	$metadata = $message->getMetaData();
	$task = $metadata->getTask();
	$text = $metadata->getParams()['text'] ?? null;

	if ($task === null || $text === null)
	{
		return null;
	}

	$recepient = $message->getRecepient();
	$text = (string)Util::trim(CTextParser::clearAllTags($text));
	$textCropped = $this->cropMessage($text);
	$locKey = ($textCropped !== '') ? 'TASKS_COMMENT_MESSAGE_ADD_WITH_TEXT' : 'TASKS_COMMENT_MESSAGE_ADD';

	$notification = new Notification(
		$locKey,
		$message
	);

	$title = new NotificationTaskTitle($task);
	$notification->addTemplate(new NotificationTemplate('#TASK_TITLE#', $title->getFormatted($recepient->getLang())));
	$notification->addTemplate(new NotificationTemplate('#TASK_COMMENT_TEXT#', $textCropped));

	$notification->setParams([
		'NOTIFY_ANSWER' => true,
		'NOTIFY_EVENT' => 'comment',
	]);

	return $notification;
}