1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Messenger.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Socialnetwork\Collab\Integration\IM;
6
7use Bitrix\Im\V2\Chat\CollabChat;
8use Bitrix\Im\V2\Chat\Update\UpdateFields;
9use Bitrix\Im\V2\Chat\Update\UpdateService;
10use Bitrix\Main\Loader;
11use Bitrix\Socialnetwork\Integration\Im\Chat\Workgroup;
12
14{
15 public static function getInstance(): ?\Bitrix\Im\V2\Service\Messenger
16 {
17 if (!Loader::includeModule('im'))
18 {
19 return null;
20 }
21
22 return \Bitrix\Im\V2\Service\Messenger::getInstance();
23 }
24
25 public static function getUpdateService(int $chatId, array $fields = [], bool $collabChatOnly = false): ?UpdateService
26 {
27 if (!Loader::includeModule('im'))
28 {
29 return null;
30 }
31
32 $chat = static::getInstance()?->getChat($chatId);
33
34 if ($collabChatOnly && !$chat instanceof CollabChat)
35 {
36 return null;
37 }
38
39 $updateFields = UpdateFields::create($fields);
40
41
42 return new UpdateService($chat, $updateFields);
43 }
44
45 public static function setManagers(int $collabId, array $managers): void
46 {
47 if (!Loader::includeModule('im'))
48 {
49 return;
50 }
51
52 Workgroup::setChatManagers(
53 [
54 'group_id' => $collabId,
55 'user_id' => $managers,
56 'set' => true,
57 ]
58 );
59 }
60
61 public static function unsetManagers(int $collabId, array $users): void
62 {
63 if (!Loader::includeModule('im'))
64 {
65 return;
66 }
67
68 Workgroup::setChatManagers(
69 [
70 'group_id' => $collabId,
71 'user_id' => $users,
72 'set' => false,
73 ]
74 );
75 }
76
77 public static function synchronizeCollabChat(int $chatId, array $fields): void
78 {
79 if (!Loader::includeModule('im'))
80 {
81 return;
82 }
83
84 static::getUpdateService($chatId, $fields, true)?->updateChat();
85 }
86}
static includeModule($moduleName)
Определения loader.php:67
static unsetManagers(int $collabId, array $users)
Определения Messenger.php:61
static setManagers(int $collabId, array $managers)
Определения Messenger.php:45
static getUpdateService(int $chatId, array $fields=[], bool $collabChatOnly=false)
Определения Messenger.php:25
static synchronizeCollabChat(int $chatId, array $fields)
Определения Messenger.php:77
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
Определения ActionUuid.php:3
$fields
Определения yandex_run.php:501