15use Bitrix\Im\V2\Common\ContextCustomer;
21use Bitrix\Tasks\Internals\TaskObject;
27 private const INTRANET_MENU_ID =
'menu_im_messenger';
40 $result = new \Bitrix\Im\V2\Result();
42 if (!$this->isPullEnabled())
47 if (!$this->isEnabled())
64 $chatFactory = ChatFactory::getInstance();
66 ->setContext($this->context)
67 ->getPrivateChat($fromUserId, $toUserId)
85 $chatFactory = ChatFactory::getInstance();
87 ->setContext($this->context)
88 ->getEntityChat($entityType, $entityId)
96 'ENTITY_TYPE' => $entityType,
97 'ENTITY_ID' => $entityId,
101 if (!$chat->hasAccess())
111 return Chat\GeneralChat::get();
120 return Chat\ChatFactory::getInstance()->getChatById($chatId);
132 if (is_string($source))
134 $source = [
'MESSAGE' => $source];
152 $deleteService->setMode($mode);
153 $deleteService->delete();
168 if ($deleteService->canDelete() < DeleteService::DELETE_HARD)
170 return (
new Result())->addError(
new MessageError(MessageError::MESSAGE_ACCESS_ERROR));
173 return Message\Delete\DisappearService::disappearMessage($message, $hours);
186 return $updateService->update($messageText);
193 public function registerTask(
int $chatId,
int $messageId, TaskObject $task): void
243 $taskService->deleteLinkByTaskId($taskId);
271 if ($entryFields[
'ID'] !== $entryFields[
'PARENT_ID'])
277 $calendar = CalendarItem::getByCalendarId($eventId);
278 if ($calendar ===
null)
282 $calendarService->updateCalendar($calendar);
287 if ($entry[
'ID'] !== $entry[
'PARENT_ID'])
293 $calendar = CalendarItem::getByCalendarId($eventId,
false);
294 if ($calendar ===
null)
298 $calendarService->unregisterCalendar($calendar);
303 private function isPullEnabled(): bool
305 return \CModule::IncludeModule(
"pull") && \CPullOptions::GetQueueServerStatus();
308 private function isEnabled(): bool
311 Loader::includeModule(
'intranet')
312 && method_exists(\
Bitrix\Intranet\
Settings\Tools\ToolsManager::class,
'checkAvailabilityByMenuId')
315 return \Bitrix\Intranet\Settings\Tools\ToolsManager::getInstance()
316 ->checkAvailabilityByMenuId(static::INTRANET_MENU_ID)
static initByRow(array $row)
static initByTaskObject(TaskObject $taskObject)
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)
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)