- Модуль: forum
- Путь к файлу: ~/bitrix/modules/forum/lib/update/livefeedconvertservicemessage.php
- Класс: BitrixForumUpdateLivefeedConvertServiceMessage
- Вызов: LivefeedConvertServiceMessage::convert
public function convert(SocialnetworkCommentAuxBase $handler, $lastId)
{
$comments = $this->getCommentsCollection(["POST_MESSAGE" => $handler::getPostText()], $lastId);
$rowsCount = $comments->count();
$lastId = 0;
if ($rowsCount > 0)
{
$dbRes = SocialnetworkLogCommentTable::getList([
"select" => ["ID", "EVENT_ID", "SOURCE_ID", "SHARE_DEST"],
"filter" => [
"SOURCE_ID" => $comments->getIdList(),
"%RATING_TYPE_ID" => "FORUM",
]
]);
$socnetComments = [];
while ($res = $dbRes->fetch())
{
$socnetComments[$res["SOURCE_ID"]] = $res;
}
$comments->rewind();
while ($comment = $comments->current())
{
$socnetInfo = array_key_exists($comment["ID"], $socnetComments) ? $socnetComments[$comment["ID"]] : ["SHARE_DEST" => ""];
if ($handler instanceof SocialnetworkCommentAuxTaskInfo && !empty($socnetInfo["SHARE_DEST"]))
{
$postMessage = self::decodeSocnetText($socnetInfo["SHARE_DEST"], 'serialized');
if (!is_array($postMessage))
{
$postMessage = self::decodeSocnetText($socnetInfo["SHARE_DEST"], 'bar');
if (empty($postMessage))
{
$postMessage = false;
}
}
if (is_array($postMessage))
{
$comment->setServiceType(ForumCommentsServiceManager::TYPE_TASK_INFO);
$serviceData = Json::encode(is_array($postMessage) ? $postMessage : []);
$comment->setServiceData($serviceData);
$comment->setPostMessage(ForumCommentsServiceManager::find([
"SERVICE_TYPE" => ForumCommentsServiceManager::TYPE_TASK_INFO
])->getText($serviceData));
$comment->setPostMessageHtml($socnetInfo["SHARE_DEST"]);
$comment->setPostMessageFilter($handler::getPostText());
}
}
elseif ($handler instanceof SocialnetworkCommentAuxCreateTask)
{
$postMessage = self::decodeSocnetText($socnetInfo["SHARE_DEST"], 'bar');
if (is_array($postMessage))
{
$comment->setServiceType(ForumCommentsServiceManager::TYPE_TASK_CREATED);
$serviceData = Json::encode(is_array($postMessage) ? $postMessage : []);
$comment->setServiceData($serviceData);
$comment->setPostMessage(ForumCommentsServiceManager::find([
"SERVICE_TYPE" => ForumCommentsServiceManager::TYPE_TASK_CREATED
])->getText($serviceData));
$comment->setPostMessageHtml($socnetInfo["SHARE_DEST"]);
$comment->setPostMessageFilter($handler::getPostText());
}
}
elseif ($handler instanceof SocialnetworkCommentAuxFileVersion && !empty($socnetInfo["SHARE_DEST"]))
{
if (false && !empty($socnetInfo["SHARE_DEST"]))
{
$comment->setPostMessageFilter($handler::getPostText());
}
}
if ($comment->state !== State::RAW)
{
$comment->save();
}
$lastId = $comment->getId();
$comments->next();
}
}
return $rowsCount < static::MESSAGE_LIMIT ? self::FINISH_EXECUTION : $lastId;
}