52 $userId = ($userId ===
null ? $USER->getId() : (int)$userId);
63 $entityType = (string)$chat[
'ENTITY_TYPE'];
64 $entityId = (int)$chat[
'ENTITY_ID'];
68 || !in_array($entityType, self::getEntityTypeList())
74 $normalizedEntityType = self::getNormalizedEntityType($entityType);
75 if ($normalizedEntityType ===
'')
80 $postProvider = Livefeed\Provider::init([
81 'ENTITY_TYPE' => $normalizedEntityType,
82 'ENTITY_ID' => $entityId,
89 if (!Loader::includeModule(
'disk'))
94 $postProvider->initSourceFields();
95 $logId = $postProvider->getLogId();
97 $commentProvider = $postProvider->getCommentProvider();
98 $commentProvider->setParentProvider($postProvider);
99 $commentProvider->setLogId($logId);
101 $fileName =
Loc::getMessage(
'SOCIALNETWORK_CHAT_CALLRECORD_FILE_NOT_FOUND');
102 if ($diskObject = File::loadById($diskObjectId))
104 $fileName = $diskObject->getName();
107 $sonetCommentData = $commentProvider->add([
108 'AUTHOR_ID' => $userId,
110 '#FILE_NAME#' => $fileName,
111 '#DISK_FILE_ID#' => $diskObjectId,
116 $sonetCommentId = (int)($sonetCommentData[
'sonetCommentId'] ?? 0);
117 $sourceCommentId = (int)($sonetCommentData[
'sourceCommentId'] ?? 0);
121 && $commentProvider->getId() === Livefeed\ForumPost::PROVIDER_ID
122 && Loader::includeModule(
'forum')
126 'UF_FORUM_MESSAGE_DOC' => [ FileUserType::NEW_FILE_PREFIX . $diskObjectId ],
130 $res = MessageTable::getList([
132 '=ID' => $sourceCommentId,
134 'select' => [
'UF_FORUM_MESSAGE_DOC' ],
137 ($messageFields = $res->fetch())
138 && !empty($messageFields[
'UF_FORUM_MESSAGE_DOC'])
141 $attachedDiskId = (int)$messageFields[
'UF_FORUM_MESSAGE_DOC'][0];
142 $renderedMessage =
'';
145 Loader::includeModule(
'disk')
146 && ($attachedObject = AttachedObject::loadById($attachedDiskId, [
'OBJECT' ]))
149 $url = \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlUfController(
'download', [
'attachedId' => $attachedDiskId ]);
150 $renderedMessage =
Loc::getMessage(
'SOCIALNETWORK_CHAT_CALLRECORD_TEXT', [
151 '#FILE_NAME#' => (!empty($url) ?
'[URL=' . $url .
']' . $fileName .
'[/URL]' : $fileName),
152 '#DISK_FILE_ID#' => $diskObjectId,
156 'POST_MESSAGE' => $renderedMessage,
158 MessageTable::update($sourceCommentId, $updateFields);
161 if ($sonetCommentId > 0)
164 'UF_SONET_COM_DOC' => $messageFields[
'UF_FORUM_MESSAGE_DOC']
166 if (!empty($renderedMessage))
168 $updateFields[
'MESSAGE'] = $renderedMessage;
176 $feed =
new Comments\Feed(
179 'type' => self::getForumFeedType($entityType),
181 'xml_id' => self::getForumFeedXmlIdPrefix($entityType) . $entityId,
189 'URL_TEMPLATES_PROFILE_VIEW' => Option::get(
'socialnetwork',
'user_page',
'/company/personal/') .
'user/#user_id#/',
190 'SKIP_USER_READ' =>
'N',
266 case self::ENTITY_TYPE_TASK:
267 $result = (Loader::includeModule(
'tasks') ? \CTasksTools::getForumIdForIntranet() : 0);
269 case self::ENTITY_TYPE_CALENDAR_EVENT:
270 $settings = \CCalendar::getSettings();
271 $result = (int)$settings[
'forum_id'];