Page MenuHomePhabricator

D4235.diff
No OneTemporary

D4235.diff

diff --git a/native/android/app/CMakeLists.txt b/native/android/app/CMakeLists.txt
--- a/native/android/app/CMakeLists.txt
+++ b/native/android/app/CMakeLists.txt
@@ -72,6 +72,8 @@
# comm native mutual code
../../cpp/CommonCpp/NativeModules
../../cpp/CommonCpp/NativeModules/InternalModules
+ ../../cpp/CommonCpp/NativeModules/PersistentStorageUtilities
+ ../../cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities
../../cpp/CommonCpp/DatabaseManagers
../../cpp/CommonCpp/Tools
../../cpp/CommonCpp/grpc/_generated
@@ -80,8 +82,7 @@
# search for all cpp files in this directory
file(GLOB SQLCIPHER "../../node_modules/@commapp/sqlcipher-amalgamation/src/*.c")
-file(GLOB COMMON_NATIVE_CODE "../../cpp/CommonCpp/**/*.cpp")
-file(GLOB COMMON_NATIVE_INTERNAL "../../cpp/CommonCpp/**/**/*.cpp")
+file(GLOB_RECURSE COMMON_NATIVE_CODE "../../cpp/CommonCpp/**/*.cpp")
file(GLOB ANDROID_NATIVE_CODE "./src/cpp/*.cpp")
file(GLOB DOUBLE_CONVERSION_SOURCES "./build/third-party-ndk/double-conversion/double-conversion/*.cc")
file(GLOB GRPC_CODE "../../cpp/CommonCpp/grpc/_generated/*.cc")
@@ -121,6 +122,10 @@
./build/third-party-ndk/folly/folly/String.cpp
./build/third-party-ndk/folly/folly/portability/SysUio.cpp
./build/third-party-ndk/folly/folly/net/NetOps.cpp
+ ./build/third-party-ndk/folly/folly/dynamic.cpp
+ ./build/third-party-ndk/folly/folly/json.cpp
+ ./build/third-party-ndk/folly/folly/json_pointer.cpp
+ ./build/third-party-ndk/folly/folly/Unicode.cpp
# double-conversion
${DOUBLE_CONVERSION_SOURCES}
@@ -130,7 +135,6 @@
# comm code
${ANDROID_NATIVE_CODE}
${COMMON_NATIVE_CODE}
- ${COMMON_NATIVE_INTERNAL}
)
add_definitions(
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#include "../../../DatabaseManagers/entities/Thread.h"
+
+#include <string>
+
+namespace comm {
+class ThreadOperations {
+public:
+ static void updateSQLiteUnreadStatus(std::string &threadID, bool unread);
+};
+} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.cpp
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/ThreadOperationsUtilities/ThreadOperations.cpp
@@ -0,0 +1,39 @@
+#include "ThreadOperations.h"
+#include "../../../DatabaseManagers/DatabaseManager.h"
+#include "Logger.h"
+#include <folly/String.h>
+#include <folly/json.h>
+#include <stdexcept>
+
+namespace comm {
+void ThreadOperations::updateSQLiteUnreadStatus(
+ std::string &threadID,
+ bool unread) {
+ std::unique_ptr<Thread> thread =
+ DatabaseManager::getQueryExecutor().getThread(threadID);
+ if (thread == nullptr) {
+ throw std::runtime_error(
+ "Attempted to update non-existing thread with ID: " + threadID);
+ }
+ folly::dynamic updatedCurrentUser;
+ try {
+ updatedCurrentUser = folly::parseJson(thread->current_user);
+ } catch (const folly::json::parse_error &e) {
+ Logger::log(
+ "Invalid json structure of current_user field of thread of id: " +
+ threadID + ". Details: " + std::string(e.what()));
+ return;
+ }
+ updatedCurrentUser["unread"] = unread;
+ try {
+ thread->current_user = folly::toJson(updatedCurrentUser);
+ } catch (const folly::json::parse_error &e) {
+ Logger::log(
+ "Failed to serialize updated current_user JSON object. Details: " +
+ std::string(e.what()));
+ return;
+ }
+
+ DatabaseManager::getQueryExecutor().replaceThread(*thread);
+}
+} // namespace comm

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 1:28 AM (21 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2577930
Default Alt Text
D4235.diff (3 KB)

Event Timeline