Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3736902
D3984.id13942.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D3984.id13942.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
@@ -1,7 +1,10 @@
#include "MessageOperationsUtilities.h"
+#include "Logger.h"
#include "MessageSpecs.h"
#include <folly/String.h>
+#include <folly/json.h>
+#include <stdexcept>
namespace comm {
ClientDBMessageInfo
@@ -72,4 +75,36 @@
return Media{id, container, thread, uri, type, extras};
}
+std::vector<ClientDBMessageInfo>
+MessageOperationsUtilities::translateStringToClientDBMessageInfos(
+ std::string &rawMessageInfosString) {
+ std::vector<ClientDBMessageInfo> clientDBMessageInfos;
+ folly::dynamic rawMessageInfos;
+ try {
+ rawMessageInfos =
+ folly::parseJson(folly::trimWhitespace(rawMessageInfosString));
+ } catch (const folly::json::parse_error &e) {
+ Logger::log(
+ "Failed to convert message into JSON object. Details: " +
+ std::string(e.what()));
+ return clientDBMessageInfos;
+ }
+ for (const auto &messageInfo : rawMessageInfos) {
+ try {
+ clientDBMessageInfos.push_back(
+ translateRawMessageInfoToClientDBMessageInfo(messageInfo));
+ } catch (const folly::TypeError &e) {
+ Logger::log(
+ "Invalid type conversion when parsing message. Details: " +
+ std::string(e.what()));
+ } catch (const std::out_of_range &e) {
+ Logger::log(
+ "Non-existing key accessed when parsing message. Details: " +
+ std::string(e.what()));
+ }
+ }
+
+ return clientDBMessageInfos;
+}
+
} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 10, 7:00 AM (10 h, 11 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2846138
Default Alt Text
D3984.id13942.diff (1 KB)
Attached To
Mode
D3984: Implement translation of raw string from notification into SQLite database entities.
Attached
Detach File
Event Timeline
Log In to Comment