• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Chat/GroupChat.php
  • Класс: BitrixImV2ChatGroupChat
  • Вызов: GroupChat::sendGreetingMessage
protected function sendGreetingMessage(?int $authorId = null)
{
	if (!$authorId)
	{
		$authorId = $this->getAuthorId();
	}
	$author = BitrixImV2EntityUserUser::getInstance($authorId);

	$messageVariant = 'CHAT';
	if ($this->getEntityType())
	{
		$messageVariant = $this->getEntityType();
	}
	$messageCode = 'IM_' . $messageVariant . '_CREATE_' . $author->getGender();

	$messageText = Loc::getMessage(
		$messageCode,
		[
			'#USER_NAME#' => htmlspecialcharsback($author->getName())
		]
	);

	CIMMessage::Add([
		'MESSAGE_TYPE' => self::IM_TYPE_CHAT,
		'TO_CHAT_ID' => $this->getChatId(),
		'FROM_USER_ID' => $author->getId(),
		'MESSAGE' => $messageText,
		'SYSTEM' => 'Y',
		'PUSH' => 'N'
	]);

	if ($authorId !== $this->getAuthorId())
	{
		$messageText = Loc::getMessage(
			'IM_CHAT_APPOINT_OWNER_' . $author->getGender(),
			[
				'#USER_1_NAME#' => htmlspecialcharsback($author->getName()),
				'#USER_2_NAME#' => htmlspecialcharsback($this->getAuthor()->getName())
			]
		);

		CIMMessage::Add([
			'MESSAGE_TYPE' => self::IM_TYPE_CHAT,
			'TO_CHAT_ID' => $this->getChatId(),
			'FROM_USER_ID' => $author->getId(),
			'MESSAGE' => $messageText,
			'SYSTEM' => 'Y',
			'PUSH' => 'N'
		]);
	}
}