1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
Chat.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Socialnetwork\Collab\Integration\IM;
6
7use Bitrix\Im\V2;
8use Bitrix\Main\Error;
9use Bitrix\Main\Loader;
10use Bitrix\Main\Result;
11use Bitrix\Socialnetwork\Collab\Registry\CollabRegistry;
12
13Loader::includeModule('im');
14
15class Chat
16{
23 public const ALLOWED_RIGHTS = [
24 'NONE',
25 'MEMBER',
26 'OWNER',
27 'MANAGER',
28 ];
29
30 public static function getCollabIdByDialog(string $dialogId): int
31 {
32 if (!Loader::includeModule('im'))
33 {
34 return 0;
35 }
36
37 $chatId = Dialog::getChatId($dialogId);
38 if ($chatId <= 0)
39 {
40 return 0;
41 }
42
43 return (int)V2\Chat::getInstance($chatId)->getEntityId();
44 }
45
46 public static function getDialogIdByCollabId(int $collabId): string
47 {
48 if (!Loader::includeModule('im'))
49 {
50 return '';
51 }
52
53 $collab = CollabRegistry::getInstance()->get($collabId);
54 if ($collab === null)
55 {
56 return '';
57 }
58
59 return $collab->getDialogId();
60 }
61
62 public static function deleteByCollabId(int $collabId): Result
63 {
64 $result = new Result();
65
66 $collab = CollabRegistry::getInstance()->get($collabId);
67 if ($collab === null)
68 {
69 $result->addError(new Error('Collab not found'));
70
71 return $result;
72 }
73
74 return static::deleteByChatId($collab->getChatId());
75 }
76
77 public static function deleteByChatId(int $chatId): Result
78 {
79 $result = new Result();
80
81 $deleteResult = V2\Chat::getInstance($chatId)->deleteChat();
82
83 $result->addErrors($deleteResult->getErrors());
84
85 return $result;
86 }
87
88 public static function updateMessagesAutoDelete(int $chatId, int $delay): Result
89 {
90 if (!Loader::includeModule('im'))
91 {
92 return new Result();
93 }
94
95 $chat = V2\Chat::getInstance($chatId);
97 }
98}
static getChatId($dialogId, $userId=null)
Определения dialog.php:93
static disappearChat(Chat $chat, int $delay)
Определения DisappearService.php:101
static getInstance()
Определения application.php:98
Определения result.php:20
Определения error.php:15
static updateMessagesAutoDelete(int $chatId, int $delay)
Определения Chat.php:88
static getDialogIdByCollabId(int $collabId)
Определения Chat.php:46
static deleteByChatId(int $chatId)
Определения Chat.php:77
static getCollabIdByDialog(string $dialogId)
Определения Chat.php:30
static deleteByCollabId(int $collabId)
Определения Chat.php:62
$result
Определения get_property_values.php:14