• Модуль: imopenlines
  • Путь к файлу: ~/bitrix/modules/imopenlines/lib/chat.php
  • Класс: BitrixImOpenLinesChat
  • Вызов: Chat::load
public function load($params)
{
	$result = false;

	if ($this->isModuleLoad())
	{
		$rawChat = ChatTable::getList([
			'filter' => [
				'=ENTITY_TYPE' => 'LINES',
				'=ENTITY_ID' => $params['USER_CODE']
			],
			'limit' => 1
		]);
		if ($chat = $rawChat->fetch())
		{
			if (
				isset($params['CONNECTOR']['chat']['description'])
				&& $chat['DESCRIPTION'] !== $params['CONNECTOR']['chat']['description']
			)
			{
				$chatManager = new CIMChat(0);
				$chatManager->SetDescription($chat['ID'], $params['CONNECTOR']['chat']['description']);
				$chat['DESCRIPTION'] = $params['CONNECTOR']['chat']['description'];
			}

			$this->chat = $chat;

			$this->isDataLoaded = true;
			$result = true;

			//TODO: Hack for telegram 22.04.2022
			$this->isNoSession($chat);
		}
		elseif ($params['ONLY_LOAD'] !== 'Y')
		{
			$addParamsChat = $this->getParamsAddChat($params);

			$chat = new CIMChat(0);
			$id = $chat->Add($addParamsChat);
			if ($id)
			{
				$rawChat = ChatTable::getById($id);
				$this->chat = $rawChat->fetch();
				$this->isCreated = true;
				$this->isDataLoaded = true;

				$result = true;
			}
		}
	}

	return $result;
}