• Модуль: im
  • Путь к файлу: ~/bitrix/modules/im/lib/V2/Chat.php
  • Класс: BitrixImV2Chat
  • Вызов: Chat::deleteUser
public function deleteUser(int $userId, bool $withMessage = true, bool $skipRecent = false): Result
{
	$relations = clone $this->getRelations();
	$userRelation = $this->getRelations()->getByUserId($userId, $this->getId());

	if ($userRelation === null)
	{
		return (new Result())->addError(new ImV2EntityUserUserError(ImV2EntityUserUserError::NOT_FOUND));
	}

	if ($this->getAuthorId() === $userId)
	{
		$this->changeAuthor();
	}

	CIMContactList::DeleteRecent($this->getId(), true, $userId);
	BitrixImLastSearch::delete('chat' . $this->getId(), $userId);

	$userRelation->delete();
	$this->updateStateAfterUserDelete($userId)->save();
	$this->sendPushUserDelete($userId, $relations);
	$this->sendEventUserDelete($userId);
	if ($withMessage)
	{
		$this->sendMessageUserDelete($userId, $skipRecent);
	}
	if ($this->getContext()->getUserId() !== $userId)
	{
		$this->sendNotificationUserDelete($userId);
	}

	return new Result();
}