3namespace Bitrix\Im\V2\Controller;
7use Bitrix\Im\V2\Chat\CommentChat;
8use Bitrix\Im\V2\Controller\Filter\ActionUuidHandler;
9use Bitrix\Im\V2\Controller\Filter\AuthorizationPrefilter;
10use Bitrix\Im\V2\Controller\Filter\AutoJoinToChat;
11use Bitrix\Im\V2\Controller\Filter\CheckChatAccess;
12use Bitrix\Im\V2\Controller\Filter\SameChatMessageFilter;
13use Bitrix\Im\V2\Controller\Filter\UpdateStatus;
14use Bitrix\Im\V2\Link\Pin\PinCollection;
15use Bitrix\Im\V2\Message;
16use Bitrix\Im\V2\Message\MessageError;
17use Bitrix\Im\V2\Message\MessageService;
18use Bitrix\Im\V2\MessageCollection;
19use Bitrix\Im\V2\Rest\RestAdapter;
20use Bitrix\Im\V2\Rest\RestConvertible;
21use Bitrix\Main\Application;
22use Bitrix\Main\Engine\ActionFilter\CloseSession;
23use Bitrix\Main\Engine\AutoWire\ExactParameter;
24use Bitrix\Main\Engine\Controller;
25use Bitrix\Main\Engine\Response\Converter;
26use Bitrix\Main\Text\Encoding;
27use Bitrix\Main\Type\ParameterDictionary;
41 function($className,
string $dialogId) {
50 function($className,
int $chatId) {
62 MessageCollection::class,
64 function ($className,
array $messageIds) {
71 function ($className,
int $commentChatId) {
78 function($className,
int $postId,
string $createIfNotExists =
'N') {
92 parent::getDefaultPreFilters(),
105 return $limit > 0 && $limit <= static::MAX_LIMIT ? $limit : static::DEFAULT_LIMIT;
110 return (
new RestAdapter(...$entities))->toRestFormat();
115 $messageLimit = $this->
getLimit($messageLimit);
116 $pinLimit = $this->
getLimit($pinLimit);
117 $messageService =
new MessageService($targetMessage ?? $chat->getLoadContextMessage($ignoreMark));
118 $messages = $messageService->getMessageContext($messageLimit, Message::REST_FIELDS)->getResult();
120 [
'CHAT_ID' => $chat->getChatId(),
'START_ID' => $chat->getStartId() ?:
null],
127 $rest = $restAdapter->toRestFormat();
129 return $messageService->fillContextPaginationData($rest,
$messages, $messageLimit);
135 $rest[
'hasNextPage'] = $realCount >= $needCount;
143 $converter =
new Converter(Converter::TO_SNAKE | Converter::TO_UPPER);
144 foreach (
$fields as $field => $value)
146 if (is_array($value))
150 elseif ((is_array($whiteList) && in_array($field, $whiteList)) || $sanitizeOnly)
152 $data[$converter->process($field)] = $value;
162 $filteredFields = [];
164 foreach ($whiteList as $allowedField)
166 if (isset(
$fields[$allowedField]))
168 $filteredFields[$allowedField] =
$fields[$allowedField];
172 return $filteredFields;
179 if (!
$message->checkAccess()->isSuccess())
181 $this->addError(
new MessageError(MessageError::ACCESS_DENIED));
190 $this->addErrors(
$result->getErrors());
200 if (
count($ids) > static::MAX_MESSAGES_COUNT)
202 $this->addError(
new MessageError(MessageError::TOO_MANY_MESSAGES));
206 $ids = array_map(
'intval', $ids);
210 if ($messageCollection->isEmpty())
212 $this->addError(
new MessageError(MessageError::NOT_FOUND));
217 return $messageCollection;
236 return $this->prepareRawValue($this->request->getPostList(),
$key)
237 ?? $this->prepareRawValue($this->request->getQueryList(),
$key)
245 if (isset($rawData[
$key]))
247 return $rawData[
$key];
257 $converter =
new Converter(Converter::TO_SNAKE | Converter::TO_UPPER | Converter::KEYS);
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
static getChatId($dialogId, $userId=null)
getChatByPostId(int $postId, bool $createIfNotExists)
toRestFormat(RestConvertible ... $entities)
convertCharToBool(string $char, bool $default=false)
load(\Bitrix\Im\V2\Chat $chat, int $messageLimit, int $pinLimit, bool $ignoreMark=false, ?Message $targetMessage=null)
prepareFields(array $fields, array $whiteList)
getMessagesByIds(array $ids)
toRestFormatWithPaginationData(array $entities, int $needCount, int $realCount)
static recursiveWhiteList($fields, $whiteList, bool $sanitizeOnly=false)
checkWhiteList(array $fields, array $whiteList)
static find(array $filter, array $order=['ID'=> 'DESC'], ?int $limit=null, ?Context $context=null)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"