3namespace Bitrix\Im\V2\Controller;
7use Bitrix\Im\V2\Chat\ChannelChat;
8use Bitrix\Im\V2\Chat\ChatError;
9use Bitrix\Im\V2\Chat\ChatFactory;
10use Bitrix\Im\V2\Chat\CollabChat;
11use Bitrix\Im\V2\Chat\CommentChat;
12use Bitrix\Im\V2\Chat\ExternalChat;
13use Bitrix\Im\V2\Chat\GeneralChat;
14use Bitrix\Im\V2\Chat\GroupChat;
15use Bitrix\Im\V2\Chat\MessagesAutoDelete\MessagesAutoDeleteConfigs;
16use Bitrix\Im\V2\Chat\OpenChannelChat;
17use Bitrix\Im\V2\Chat\OpenChat;
18use Bitrix\Im\V2\Chat\OpenLineChat;
19use Bitrix\Im\V2\Chat\Param\Params;
20use Bitrix\Im\V2\Chat\ExtendedType;
21use Bitrix\Im\V2\Controller\Filter\DiskQuickAccessGrantor;
22use Bitrix\Im\V2\Permission;
23use Bitrix\Im\V2\Chat\Update\UpdateFields;
24use Bitrix\Im\V2\Controller\Chat\Pin;
25use Bitrix\Im\V2\Controller\Filter\ChatTypeFilter;
26use Bitrix\Im\V2\Controller\Filter\CheckActionAccess;
27use Bitrix\Im\V2\Controller\Filter\CheckChatAccess;
28use Bitrix\Im\V2\Controller\Filter\CheckFileAccess;
29use Bitrix\Im\V2\Controller\Filter\ExtendPullWatchPrefilter;
30use Bitrix\Im\V2\Controller\Filter\UpdateStatus;
31use Bitrix\Im\V2\Entity\File\ChatAvatar;
32use Bitrix\Im\V2\Entity\User\UserPopupItem;
33use Bitrix\Im\V2\Message;
34use Bitrix\Im\V2\Relation\AddUsersConfig;
35use Bitrix\Im\V2\Rest\RestAdapter;
36use Bitrix\Im\V2\Chat\Update\UpdateService;
37use Bitrix\Im\V2\Result;
38use Bitrix\Intranet\ActionFilter\IntranetUser;
39use Bitrix\Main\Engine\ActionFilter\Base;
40use Bitrix\Main\Engine\AutoWire\ExactParameter;
41use Bitrix\Main\Engine\CurrentUser;
42use Bitrix\Main\Engine\Response\Converter;
54 'TYPE' => $this->getValidatedType(
55 $filter->getAction()->getArguments()[
'fields'][
'type'] ??
''
57 'ENTITY_TYPE' => $this->getValidatedEntityType(
58 $filter->getAction()->getArguments()[
'fields'][
'entityType'] ??
null
148 'deleteManagers' => [
155 'setManageUsersAdd' => [
161 'setManageUsersDelete' => [
173 'setManageSettings' => [
179 'setMessagesAutoDeleteDelay' => [
185 'setManageMessages' => [
208 OpenChannelChat::class,
214 'extendPullWatch' => [
216 new ChatTypeFilter([OpenChat::class, OpenLineChat::class, ChannelChat::class]),
237 function ($className, $id) {
238 return \Bitrix\Im\V2\Chat::getInstance((
int)$id);
256 int $messageLimit =
Chat\Message::DEFAULT_LIMIT,
258 string $ignoreMark =
'N'
276 int $messageLimit =
Chat\Message::DEFAULT_LIMIT,
295 return (
new RestAdapter($chat))->toRestFormat([
'POPUP_DATA_EXCLUDE' => [UserPopupItem::class]]);
310 $chats = \Bitrix\Im\V2\Chat::getSharedChatsWithUser(
$userId, $this->
getLimit($limit), $offset);
311 \Bitrix\Im\V2\Chat::fillSelfRelations($chats);
314 foreach ($chats as $chat)
316 $result[
'chats'][] = $chat->toRestFormat([
'CHAT_SHORT_FORMAT' =>
true,
'CHAT_WITH_DATE_MESSAGE' =>
true]);
330 if ($chatId ===
false || $chatId === 0)
337 return [
'dialogId' =>
"chat{$chatId}"];
347 return $this->convertKeysToCamelCase(
$result->getResult());
355 \Bitrix\Im\V2\Chat::readAllChats((
int)
$user->getId());
375 $chat->startRecordVoice();
377 return [
'result' =>
true];
385 $fields[
'type'] = $this->getValidatedType(
$fields[
'type'] ??
null);
386 $fields[
'entityType'] = $this->getValidatedEntityType(
$fields[
'entityType'] ??
null);
390 ||
$fields[
'entityType'] !==
'VIDEOCONF'
391 || !isset(
$fields[
'conferencePassword'])
394 unset(
$fields[
'conferencePassword']);
397 if (isset(
$fields[
'copilotMainRole']))
400 'paramName' => Params::COPILOT_MAIN_ROLE,
401 'paramValue' =>
$fields[
'copilotMainRole']
406 if (isset(
$data[
'OWNER_ID']))
414 $this->addErrors(
$result->getErrors());
418 return $this->convertKeysToCamelCase(
$result->getResult());
427 $converter =
new Converter(Converter::TO_SNAKE | Converter::TO_UPPER | Converter::KEYS);
430 $result = $updateService->updateChat();
433 $this->addError(
$result->getErrors()[0]);
438 return [
'result' =>
true];
453 $this->addError(
$result->getErrors()[0]);
458 return [
'result' =>
true];
467 $hideHistoryBool = $hideHistory ===
null ? null : $this->
convertCharToBool($hideHistory,
true);
468 $chat->addUsers($userIds,
new AddUsersConfig(hideHistory: $hideHistoryBool));
470 return [
'result' =>
true];
480 return [
'result' =>
true];
490 $chat->extendPullWatch();
493 return [
'result' =>
true];
505 $this->addErrors(
$result->getErrors());
510 return [
'result' =>
true];
524 return $this->convertKeysToCamelCase(
$result->getErrors());
539 return $this->convertKeysToCamelCase(
$result->getErrors());
550 $result = $chat->validateColor();
553 return $this->convertKeysToCamelCase(
$result->getErrors());
556 $chat->setColor($color);
561 return $this->convertKeysToCamelCase(
$result->getErrors());
576 $this->addErrors(
$result->getErrors());
581 return [
'result' =>
true];
593 return $this->convertKeysToCamelCase(
$result->getErrors());
596 return [
'result' =>
true];
608 return $this->convertKeysToCamelCase(
$result->getErrors());
611 return [
'avatarId' =>
$result->getResult()];
632 $this->addErrors(
$result->getErrors());
638 'messagesAutoDeleteConfigs' =>
$result->getResult()?->showDefaultValues()?->toRestFormat() ?? [],
647 $chat->setAuthorId($ownerId);
651 return $this->convertKeysToCamelCase(
$result->getErrors());
662 $chat->setManagers($userIds);
666 return $this->convertKeysToCamelCase(
$result->getErrors());
679 return [
'result' =>
true];
689 return [
'result' =>
true];
697 $chat->setManageUsersAdd(mb_strtoupper($rightsLevel));
701 return $this->convertKeysToCamelCase(
$result->getErrors());
712 $chat->setManageUsersDelete(mb_strtoupper($rightsLevel));
716 return $this->convertKeysToCamelCase(
$result->getErrors());
727 $chat->setManageUI(mb_strtoupper($rightsLevel));
731 return $this->convertKeysToCamelCase(
$result->getErrors());
742 $chat->setManageSettings(mb_strtoupper($rightsLevel));
746 return $this->convertKeysToCamelCase(
$result->getErrors());
758 $chat->setManageMessages(mb_strtoupper($rightsLevel));
762 return $this->convertKeysToCamelCase(
$result->getErrors());
782 return [
'result' =>
true];
792 return [
'result' =>
true];
809 return [
'result' =>
true];
812 private function getValidatedType(?
string $type): string
816 'CHANNEL' => \Bitrix\Im\V2\Chat::IM_TYPE_CHANNEL,
817 'COPILOT' => \Bitrix\Im\V2\Chat::IM_TYPE_COPILOT,
818 'COLLAB' => \Bitrix\Im\V2\Chat::IM_TYPE_COLLAB,
819 'AI_ASSISTANT' => \Bitrix\Im\V2\Chat::IM_TYPE_AI_ASSISTANT,
820 default => \Bitrix\Im\V2\Chat::IM_TYPE_CHAT,
824 private function getValidatedEntityType(?
string $entityType): ?string
826 $convertedEntityType = (string)(
new Converter(Converter::TO_UPPER))->process($entityType);
827 $extendedType = ExtendedType::tryFrom($convertedEntityType);
829 return $extendedType?->isInternal() ? null : $convertedEntityType;
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
static getChatId($dialogId, $userId=null)
static sortPin(\Bitrix\Im\V2\Chat $chat, int $newPosition, int $userId)
static unread($dialogId, $unread, $userId=null, ?int $markedId=null, ?string $itemTypes=null)
static pin($dialogId, $pin, $userId=null)
const MAX_PINNED_CHATS_ERROR
const INVALID_PIN_POSITION
const USER_ID_EMPTY_ERROR
deleteManagers(array $userIds, bool $sendPush=true)
addManagers(array $userIds, bool $sendPush=true)
static create(array $fields)
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)
addManagersAction(GroupChat $chat, array $userIds)
addUsersAction(\Bitrix\Im\V2\Chat $chat, array $userIds, ?string $hideHistory=null)
loadInContextAction(Message $message, int $messageLimit=Chat\Message::DEFAULT_LIMIT, int $pinLimit=Pin::DEFAULT_LIMIT)
setManageUsersAddAction(\Bitrix\Im\V2\Chat $chat, string $rightsLevel)
setColorAction(\Bitrix\Im\V2\Chat $chat, string $color)
deleteManagersAction(GroupChat $chat, array $userIds)
unpinAction(\Bitrix\Im\V2\Chat $chat, CurrentUser $user)
setManageUsersDeleteAction(\Bitrix\Im\V2\Chat $chat, string $rightsLevel)
setTitleAction(\Bitrix\Im\V2\Chat $chat, string $title)
setManageMessagesAction(\Bitrix\Im\V2\Chat $chat, string $rightsLevel)
getPrimaryAutoWiredParameter()
setManageSettingsAction(\Bitrix\Im\V2\Chat $chat, string $rightsLevel)
extendPullWatchAction(\Bitrix\Im\V2\Chat $chat)
readAllAction(CurrentUser $user)
joinAction(\Bitrix\Im\V2\Chat $chat)
deleteAction(\Bitrix\Im\V2\Chat $chat)
unreadAction(\Bitrix\Im\V2\Chat $chat)
setOwnerAction(\Bitrix\Im\V2\Chat $chat, int $ownerId)
pinAction(\Bitrix\Im\V2\Chat $chat, CurrentUser $user)
listSharedAction(array $filter, int $limit=self::DEFAULT_LIMIT, int $offset=0)
loadAction(\Bitrix\Im\V2\Chat $chat, int $messageLimit=Chat\Message::DEFAULT_LIMIT, int $pinLimit=Pin::DEFAULT_LIMIT, string $ignoreMark='N')
shallowLoadAction(\Bitrix\Im\V2\Chat $chat)
deleteUserAction(\Bitrix\Im\V2\Chat $chat, int $userId)
setManagersAction(\Bitrix\Im\V2\Chat $chat, array $userIds)
sortPinAction(\Bitrix\Im\V2\Chat $chat, int $newPosition, CurrentUser $user)
updateAvatarAction(\Bitrix\Im\V2\Chat $chat, string $avatar)
readAction(\Bitrix\Im\V2\Chat $chat, string $onlyRecent='N')
getAction(\Bitrix\Im\V2\Chat $chat)
setAvatarAction(\Bitrix\Im\V2\Chat $chat, string $avatarBase64)
setAvatarIdAction(\Bitrix\Im\V2\Chat $chat, int $avatarId)
setDescriptionAction(\Bitrix\Im\V2\Chat $chat, string $description)
startRecordVoiceAction(\Bitrix\Im\V2\Chat $chat)
getDialogIdAction(string $externalId)
setManageUIAction(\Bitrix\Im\V2\Chat $chat, string $rightsLevel)
updateAction(GroupChat $chat, array $fields)
static disappearChat(Chat $chat, int $delay)
static disappearCollab(Chat\CollabChat $chat, int $delay)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(Loader::includeModule( 'bitrix24')) elseif(Loader::includeModule('intranet') &&CIntranetUtils::getPortalZone() !=='ru') $description