- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/V2/Chat.php
- Класс: BitrixImV2Chat
- Вызов: Chat::sendEventUserDelete
protected function sendEventUserDelete(int $userId): void
{
$user = ImV2EntityUserUser::getInstance($userId);
if ($user->isBot())
{
IMBot::changeChatMembers($this->getId(), $userId);
IMBot::onLeaveChat('chat'.$this->getId(), [
'CHAT_TYPE' => $this->getType(),
'MESSAGE_TYPE' => $this->getType(),
'BOT_ID' => $userId,
'USER_ID' => $this->getContext()->getUserId(),
"CHAT_AUTHOR_ID" => $this->getAuthorId(),
"CHAT_ENTITY_TYPE" => $this->getEntityType(),
"CHAT_ENTITY_ID" => $this->getEntityId(),
]);
}
if (!empty($this->getEntityType()))
{
$converter = new MainEngineResponseConverter(MainEngineResponseConverter::TO_CAMEL | MainEngineResponseConverter::UC_FIRST);
$eventCode = $converter->process($this->getEntityType());
//$eventCode = str_replace('_', '', ucfirst(ucwords(mb_strtolower($chatEntityType), '_')));
foreach(GetModuleEvents("im", "OnChatUserDeleteEntityType".$eventCode, true) as $arEvent)
{
ExecuteModuleEventEx($arEvent, array([
'CHAT_ID' => $this->getId(),
'USER_ID' => $userId,
]));
}
}
}