- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/lib/call/call.php
- Класс: BitrixImCallCall
- Вызов: Call::searchActive
static function searchActive($type, $provider, $entityType, $entityId, $currentUserId = 0)
{
if (!$currentUserId)
{
$currentUserId = BitrixImUser::getInstance()->getId();
}
$query = CallTable::query()
->addSelect("*")
->where("TYPE", $type)
->where("PROVIDER", $provider)
->where("ENTITY_TYPE", $entityType)
->whereNull("END_DATE")
->setOrder(["ID" => "DESC"])
->setLimit(1);
if ($entityType === EntityType::CHAT && strpos($entityId, "chat") !== 0)
{
$query->where("INITIATOR_ID", $entityId);
$query->where("ENTITY_ID", $currentUserId);
}
else
{
$query->where("ENTITY_ID", $entityId);
}
$callFields = $query->exec()->fetch();
if(!$callFields)
{
return null;
}
$instance = static::createWithArray($callFields);
if($instance->hasActiveUsers(false))
{
return $instance;
}
return null;
}