- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::dialogUsersList
static function dialogUsersList($params, $offset, CRestServer $server): Array
{
$params = array_change_key_case($params, CASE_UPPER);
if (!BitrixImCommon::isDialogId($params['DIALOG_ID']))
{
throw new BitrixRestRestException("Dialog ID can't be empty", "DIALOG_ID_EMPTY", CRestServer::STATUS_WRONG_REQUEST);
}
if (!BitrixImDialog::hasAccess($params['DIALOG_ID']))
{
throw new BitrixRestRestException("You do not have access to the specified dialog", "ACCESS_ERROR", CRestServer::STATUS_FORBIDDEN);
}
$chatId = BitrixImDialog::getChatId($params['DIALOG_ID']);
if (!$chatId)
{
throw new BitrixRestRestException("You don't have access to this chat", "ACCESS_ERROR", CRestServer::STATUS_WRONG_REQUEST);
}
$countFilter = [
'=CHAT_ID' => $chatId,
'=USER.ACTIVE' => 'Y',
];
if (
isset($params['SKIP_EXTERNAL']) && $params['SKIP_EXTERNAL'] === 'Y'
|| isset($params['SKIP_EXTERNAL_EXCEPT_TYPES']))
{
$options['SKIP_EXTERNAL'] = 'Y';
$options['SKIP_EXTERNAL_EXCEPT_TYPES'] = array_map('trim', mb_split(',', $params['SKIP_EXTERNAL_EXCEPT_TYPES']));
$exceptType = $options['SKIP_EXTERNAL_EXCEPT_TYPES'] ?? [];
$countFilter['!=USER.EXTERNAL_AUTH_ID'] = BitrixImModelUserTable::filterExternalUserTypes($exceptType);
}
$options['LIMIT'] = self::getLimit($params);
$options['JSON'] = true;
if (isset($params['LAST_ID']) && (int)$params['LAST_ID'] >= 0)
{
$options['LAST_ID'] = (int)$params['LAST_ID'];
return BitrixImChat::getUsers($chatId, $options);
}
$counter = BitrixImModelRelationTable::getList([
'select' => ['CNT' => new BitrixMainEntityExpressionField('CNT', 'COUNT(1)')],
'filter' => $countFilter
])->fetch();
$options['OFFSET'] = self::getOffset($offset, $params);
$result = Array();
if ($counter && $counter["CNT"] > 0)
{
$result = BitrixImChat::getUsers($chatId, $options);
}
return self::setNavData(
$result,
array(
"count" => $counter['CNT'],
"offset" => $options['OFFSET']
)
);
}