- Модуль: imopenlines
- Путь к файлу: ~/bitrix/modules/imopenlines/lib/chat.php
- Класс: BitrixImOpenLinesChat
- Вызов: Chat::intercept
public function intercept($userId): bool
{
$result = false;
if(
$this->isDataLoaded() &&
$this->chat['AUTHOR_ID'] > 0 &&
$this->chat['AUTHOR_ID'] != $userId
)
{
$previousOwnerId = $this->chat['AUTHOR_ID'];
$resultAnswer = $this->answer($userId, false, true);
if($resultAnswer->isSuccess())
{
$previousOwner = User::getInstance($previousOwnerId);
$newOwner = User::getInstance($userId);
CIMChat::AddMessage([
"FROM_USER_ID" => $userId,
"TO_CHAT_ID" => $this->chat['ID'],
"MESSAGE" => Loc::getMessage('IMOL_CHAT_INTERCEPT_'.$newOwner->getGender(), [
'#USER_1#' => '[USER='.$newOwner->getId().'][/USER]',
'#USER_2#' => '[USER='.$previousOwner->getId().'][/USER]'
]),
"SYSTEM" => 'Y',
]);
$result = true;
}
}
return $result;
}