diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilities.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilities.cpp new file mode 100644 --- /dev/null +++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/MessageOperationsUtilities/MessageOperationsUtilities.cpp @@ -0,0 +1,24 @@ +#include "MessageOperationsUtilities.h" +#include "MessageSpecs.h" + +#include + +namespace comm { +Media MessageOperationsUtilities::translateMediaToClientDBMediaInfo( + const folly::dynamic &rawMediaInfo, + const std::string &container, + const std::string &thread) { + std::string id = rawMediaInfo["id"].asString(); + std::string uri = rawMediaInfo["uri"].asString(); + std::string type = rawMediaInfo["type"].asString(); + folly::dynamic extrasData = + folly::dynamic::object("dimensions", rawMediaInfo["dimensions"])( + "loop", (type == "video") ? rawMediaInfo["loop"] : false); + if (rawMediaInfo.count("localMediaSelection")) { + extrasData["local_media_selection"] = rawMediaInfo["localMediaSelection"]; + } + std::string extras = folly::toJson(extrasData); + return Media{id, container, thread, uri, type, extras}; +} + +} // namespace comm