Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/socialnetwork/lib/Collab/Integration/IM/ |
Upload File : |
<?php declare(strict_types=1); namespace Bitrix\Socialnetwork\Collab\Integration\IM; use Bitrix\Im\V2; use Bitrix\Main\Error; use Bitrix\Main\Loader; use Bitrix\Main\Result; use Bitrix\Socialnetwork\Collab\Registry\CollabRegistry; Loader::includeModule('im'); class Chat { /** * @see V2\Chat::MANAGE_RIGHTS_NONE, * @see V2\Chat::MANAGE_RIGHTS_MEMBER, * @see V2\Chat::MANAGE_RIGHTS_OWNER, * @see V2\Chat::MANAGE_RIGHTS_MANAGERS, */ public const ALLOWED_RIGHTS = [ 'NONE', 'MEMBER', 'OWNER', 'MANAGER', ]; public static function getCollabIdByDialog(string $dialogId): int { if (!Loader::includeModule('im')) { return 0; } $chatId = Dialog::getChatId($dialogId); if ($chatId <= 0) { return 0; } return (int)V2\Chat::getInstance($chatId)->getEntityId(); } public static function getDialogIdByCollabId(int $collabId): string { if (!Loader::includeModule('im')) { return ''; } $collab = CollabRegistry::getInstance()->get($collabId); if ($collab === null) { return ''; } return $collab->getDialogId(); } public static function deleteByCollabId(int $collabId): Result { $result = new Result(); $collab = CollabRegistry::getInstance()->get($collabId); if ($collab === null) { $result->addError(new Error('Collab not found')); return $result; } return static::deleteByChatId($collab->getChatId()); } public static function deleteByChatId(int $chatId): Result { $result = new Result(); $deleteResult = V2\Chat::getInstance($chatId)->deleteChat(); $result->addErrors($deleteResult->getErrors()); return $result; } public static function updateMessagesAutoDelete(int $chatId, int $delay): Result { if (!Loader::includeModule('im')) { return new Result(); } $chat = V2\Chat::getInstance($chatId); return V2\Message\Delete\DisappearService::disappearChat($chat, $delay); } }