- Модуль: im
- Путь к файлу: ~/bitrix/modules/im/classes/general/im_rest.php
- Класс: CIMRestService
- Вызов: CIMRestService::chatFileCollectionGet
static function chatFileCollectionGet($arParams, $n, CRestServer $server)
{
$arParams = array_change_key_case($arParams, CASE_UPPER);
$filter = [
'CHAT_ID' => $arParams['CHAT_ID'] ?? null,
];
$limit = self::getLimit($arParams);
if (!isset($filter['CHAT_ID']))
{
throw new BitrixRestRestException('CHAT_ID can`t be empty', 'CHAT_ID_EMPTY', CRestServer::STATUS_WRONG_REQUEST);
}
$chatId = $filter['CHAT_ID'];
$chat = BitrixImV2Chat::getInstance($chatId);
if (!$chat->hasAccess())
{
throw new BitrixRestRestException('You do not have access to this chat', BitrixImV2RestRestError::ACCESS_ERROR, CRestServer::STATUS_FORBIDDEN);
}
$startId = $chat->getStartId();
if ($startId > 0)
{
$filter['START_ID'] = $startId;
}
$files = new BitrixImV2LinkFileFileCollection();
foreach (BitrixImV2LinkFileFileItem::ALLOWED_SUBTYPE as $subtype)
{
$filter['SUBTYPE'] = $subtype;
$filesBySubtype = BitrixImV2LinkFileFileCollection::find($filter, [], $limit);
foreach ($filesBySubtype as $fileBySubtype)
{
$files[] = $fileBySubtype;
}
}
return (new BitrixImV2RestRestAdapter($files))->toRestFormat();
}