Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3525989
D3983.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D3983.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D3983: Implement translation of message JSON object into SQLite database entities
Attached
Detach File
Event Timeline
Log In to Comment