• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/call/integration/chat.php
  • Класс: BitrixImCallIntegrationChat
  • Вызов: Chat::onUserAdd
public function onUserAdd($userId)
{
	if (!$this->canExtendChat())
	{
		return false;
	}
	if($this->chatFields['message_type'] == IM_MESSAGE_PRIVATE)
	{
		$chat = new CIMChat();

		$users = $this->chatUsers;
		$users[] = $userId;

		$chatId = $chat->add(['USERS' => $users]);
		if (!$chatId)
		{
			return false;
		}

		if($this->call)
		{
			$this->call->setAssociatedEntity(static::getEntityType(), 'chat'.$chatId);
		}
	}
	else
	{
		$chat = new CIMChat();
		$chatId = BitrixImDialog::getChatId($this->getEntityId());
		$result = $chat->addUser($chatId, $userId);
	}

	return true;
}