Page MenuHomePhabricator

D3983.diff
No OneTemporary

D3983.diff

diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilities.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilities.cpp
--- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilities.cpp
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilities.cpp
@@ -4,6 +4,57 @@
#include <folly/String.h>
namespace comm {
+ClientDBMessageInfo
+MessageOperationsUtilities::translateRawMessageInfoToClientDBMessageInfo(
+ const folly::dynamic &rawMessageInfo) {
+ std::string id = rawMessageInfo.count("id")
+ ? rawMessageInfo["id"].asString()
+ : rawMessageInfo["localID"].asString();
+ std::string thread = rawMessageInfo["threadID"].asString();
+ std::string user = rawMessageInfo["creatorID"].asString();
+
+ std::unique_ptr<std::string> localID = nullptr;
+ if (rawMessageInfo.count("localID")) {
+ localID =
+ std::make_unique<std::string>(rawMessageInfo["localID"].asString());
+ }
+
+ int type = rawMessageInfo["type"].asInt();
+ MessageType messageType = static_cast<MessageType>(type);
+ int64_t time = rawMessageInfo["time"].asInt();
+
+ std::unique_ptr<int> futureType = nullptr;
+ if (messageType == MessageType::UNSUPPORTED) {
+ futureType = std::make_unique<int>(
+ rawMessageInfo["unsupportedMessageInfo"]["type"].asInt());
+ }
+
+ std::unique_ptr<std::string> content = nullptr;
+ if (messageSpecsHolder.find(messageType) != messageSpecsHolder.end()) {
+ content = messageSpecsHolder.at(messageType)
+ ->messageContentForClientDB(rawMessageInfo);
+ }
+ std::vector<Media> mediaVector;
+ if (messageType == MessageType::IMAGES ||
+ messageType == MessageType::MULTIMEDIA) {
+ for (const auto &media : rawMessageInfo["media"]) {
+ mediaVector.push_back(
+ translateMediaToClientDBMediaInfo(media, id, thread));
+ }
+ }
+ return {
+ Message{
+ id,
+ std::move(localID),
+ thread,
+ user,
+ type,
+ std::move(futureType),
+ std::move(content),
+ time},
+ std::move(mediaVector)};
+}
+
Media MessageOperationsUtilities::translateMediaToClientDBMediaInfo(
const folly::dynamic &rawMediaInfo,
const std::string &container,

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 7:04 PM (8 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700849
Default Alt Text
D3983.diff (2 KB)

Event Timeline