3namespace Bitrix\Im\V2\Service;
5use Bitrix\Im\V2\Application;
7use Bitrix\Im\V2\Chat\GroupChat;
8use Bitrix\Im\V2\Chat\PrivateChat;
9use Bitrix\Im\V2\Chat\EntityChat;
10use Bitrix\Im\V2\Chat\NullChat;
11use Bitrix\Im\V2\Link\Calendar\CalendarItem;
12use Bitrix\Im\V2\Link\Calendar\CalendarService;
13use Bitrix\Im\V2\Link\Task\TaskService;
14use Bitrix\Im\V2\Entity\Task\TaskItem;
15use Bitrix\Im\V2\Chat\ChatFactory;
16use Bitrix\Im\V2\Common\ContextCustomer;
17use Bitrix\Im\V2\Message;
18use Bitrix\Im\V2\Message\Delete\DeleteService;
19use Bitrix\Im\V2\Message\Delete\DeletionMode;
20use Bitrix\Im\V2\Message\MessageError;
21use Bitrix\Im\V2\MessageCollection;
22use Bitrix\Im\V2\Permission\Action;
23use Bitrix\Main\Loader;
24use Bitrix\Main\Result;
25use Bitrix\Tasks\Internals\TaskObject;
31 private const INTRANET_MENU_ID =
'menu_im_messenger';
46 $result = new \Bitrix\Im\V2\Result();
48 if (!$this->isPullEnabled())
53 if (!$this->isEnabled())
77 $chatFactory = ChatFactory::getInstance();
79 ->setContext($this->context)
80 ->getPrivateChat($fromUserId, $toUserId)
93 return ChatFactory::getInstance()->getEntityChat($entityType,
$entityId);
118 foreach ($chatIds as $chatId)
123 if (empty($chats) || !$checkAccess)
128 $currentUserId = $this->getContext()->getUserId();
134 return array_filter($chats,
static fn (
Chat $chat) => $chat->checkAccess($currentUserId)->isSuccess());
146 if (is_string($source))
148 $source = [
'MESSAGE' => $source];
156 return \Bitrix\Im\V2\Chat\ChatFactory::getInstance()->addChat(
$fields);
170 $deleteService = DeleteService::getInstanceByMessage(
$message);
171 $deleteService->setMode(DeletionMode::tryFrom($mode));
172 $deleteService->delete();
186 $deleteService = DeleteService::getInstanceByMessage(
$message);
187 if ($deleteService->canDelete(
$message->getId()) !== DeletionMode::Complete)
205 return $updateService->update($messageText);
219 if (!$chat->checkAccess()->isSuccess() || !$chat->canDo(Action::CreateTask))
263 $taskService->deleteLinkByTaskId($taskId);
291 if ($entryFields[
'ID'] !== $entryFields[
'PARENT_ID'])
297 $calendar = CalendarItem::getByCalendarId($eventId);
298 if ($calendar ===
null)
302 $calendarService->updateCalendar($calendar);
307 if ($entry[
'ID'] !== $entry[
'PARENT_ID'])
313 $calendar = CalendarItem::getByCalendarId($eventId,
false);
314 if ($calendar ===
null)
318 $calendarService->unregisterCalendar($calendar);
323 private function isPullEnabled(): bool
325 return \CModule::IncludeModule(
"pull") && \CPullOptions::GetQueueServerStatus();
328 private function isEnabled(): bool
332 && method_exists(\
Bitrix\Intranet\
Settings\Tools\ToolsManager::class,
'checkAvailabilityByMenuId')
335 return \Bitrix\Intranet\Settings\Tools\ToolsManager::getInstance()
336 ->checkAvailabilityByMenuId(static::INTRANET_MENU_ID)
if(! $messageFields||!isset($messageFields['message_id'])||!isset($messageFields['status'])||!CModule::IncludeModule("messageservice")) $messageId
static initByRow(array $row)
static initByTaskObject(TaskObject $taskObject)
static disappearMessage(Message $message, int $delay)
const MESSENGER_NOT_ENABLED
static unregisterCalendar(int $eventId, array $entry)
deleteMessage(Message $message, int $mode=0)
unregisterTask(array $taskData, bool $saveDelete)
static updateCalendar(int $eventId, array $entryFields)
updateTask(TaskObject $task)
getPrivateChat(int $fromUserId, int $toUserId)
createChat(array $fields)
getChats(array $chatIds, bool $checkAccess=false)
updateMessage(Message $message, ?string $messageText)
registerTask(int $chatId, int $messageId, TaskObject $task)
getEntityChat(string $entityType, string $entityId)
disappearMessage(Message $message, int $hours)
createMessage($source=null)
static includeModule($moduleName)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)