3namespace Bitrix\Im\V2\Chat\Update;
5use Bitrix\Im\V2\Analytics\ChatAnalytics;
7use Bitrix\Im\V2\Chat\Converter;
8use Bitrix\Im\V2\Entity\File\ChatAvatar;
9use Bitrix\Im\V2\Integration\HumanResources\Structure;
10use Bitrix\Im\V2\Integration\Socialnetwork\Collab\Collab;
11use Bitrix\Im\V2\Integration\Socialnetwork\Group;
12use Bitrix\Im\V2\Relation\AddUsersConfig;
13use Bitrix\Im\V2\Relation\DeleteUserConfig;
14use Bitrix\Im\V2\Result;
34 if (!$convertResult->isSuccess())
36 return $convertResult;
46 return $result->setResult($this->chat);
50 ->sendMessageAfterUpdateAvatar()
57 ChatAnalytics::blockSingleUserEvents($this->chat);
67 ChatAnalytics::unblockSingleUserEventsByChat($this->chat);
69 return $result->setResult($this->chat);
78 if (!isset($newType) || $this->chat->getType() === $newType)
83 $convertResult = (
new Converter($this->chat->getId(), $newType))->convert();
85 if (!$convertResult->isSuccess())
87 return $result->addErrors($convertResult->getErrors());
90 $this->newChatType = $newType;
93 $this->chat = Chat\GroupChat::getInstance($this->chat->getChatId());
100 $searchable = $this->updateFields->getSearchable();
101 $currentType = $this->chat->getType();
102 $newType = $this->updateFields->getType();
106 $currentType === Chat::IM_TYPE_CHAT && $searchable ===
'Y' => \Bitrix\Im\V2\Chat::IM_TYPE_OPEN,
107 $currentType === Chat::IM_TYPE_OPEN && $searchable ===
'N' => \Bitrix\Im\V2\Chat::IM_TYPE_CHAT,
108 $currentType === Chat::IM_TYPE_CHANNEL && $searchable ===
'Y' => \Bitrix\Im\V2\Chat::IM_TYPE_OPEN_CHANNEL,
109 $currentType === Chat::IM_TYPE_OPEN_CHANNEL && $searchable ===
'N' => \Bitrix\Im\V2\Chat::IM_TYPE_CHANNEL,
119 $addedUsers = array_unique(array_merge(
132 $deletedUsers = $this->updateFields->getDeletedUsers();
134 foreach ($deletedUsers as
$userId)
144 $addManagers = $this->updateFields->getAddedManagers();
146 if (empty($addManagers))
151 $this->chat->addManagers($addManagers,
false);
158 $deleteManagers = $this->updateFields->getDeletedManagers();
160 if (empty($deleteManagers))
165 $this->chat->deleteManagers($deleteManagers,
false);
172 $addNodes = $this->updateFields->getAddedDepartments();
174 if (empty($addNodes))
179 (
new Structure($this->chat))->link($addNodes);
181 foreach ($addNodes as $node)
191 $deleteNodes = $this->updateFields->getDeletedDepartments();
193 if (empty($deleteNodes))
198 $currentNodes = (
new Structure($this->chat))->getNodesAccessCodes();
200 foreach ($deleteNodes as
$key => $node)
202 if (!in_array($node, $currentNodes,
true))
204 unset($deleteNodes[
$key]);
208 (
new Structure($this->chat))->unlink($deleteNodes);
210 foreach ($deleteNodes as $node)
220 $avatarId = $this->updateFields->getAvatar();
221 if (!isset($avatarId))
226 (
new ChatAvatar($this->chat))->update($avatarId,
false,
false,
true);
233 $avatarId = $this->updateFields->getAvatar();
234 if (!isset($avatarId))
239 $this->chat->sendMessageUpdateAvatar();
246 if (!\
Bitrix\
Main\Loader::includeModule(
"pull"))
253 'command' =>
'chatUpdate',
256 'chat' => $this->chat->toPullFormat(),
262 if ($this->chat->needToSendPublicPull())
264 \CPullWatch::AddToStack(
'IM_PUBLIC_' . $this->chat->getId(), $pushMessage);
272 if (isset($this->newChatType))
282 if ($this->chat->getDescription() ===
$fields[
'DESCRIPTION'])
294 $diff = fn(
string $key) => $currentData[
$key] !== $prevData[
$key];
296 if ($diff(
'description'))
298 $analytics->addEditDescription();
303 $analytics->addSetType();
309 $diff(
'manageUsersAdd') ||
310 $diff(
'manageUsersDelete') ||
311 $diff(
'manageMessages')
314 $analytics->addEditPermissions();
321 'description' => $this->chat->getDescription(),
322 'type' => $this->chat->getType(),
323 'owner' => $this->chat->getAuthorId(),
324 'manageUI' => $this->chat->getManageUI(),
325 'manageUsersAdd' => $this->chat->getManageUsersAdd(),
326 'manageUsersDelete' => $this->chat->getManageUsersDelete(),
327 'manageMessages' => $this->chat->getManageMessages(),
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
compareAnalyticsData(array $prevData)
sendMessageAfterUpdateAvatar()
__construct(Chat\GroupChat $chat, UpdateFields $updateFields)
UpdateFields $updateFields
filterFieldsByDifference(array $fields)
static add($recipient, array $parameters, $channelType=\CPullChannel::TYPE_PRIVATE)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(empty($signedUserToken)) $key