Page MenuHomePhabricator

D12249.id41158.diff
No OneTemporary

D12249.id41158.diff

diff --git a/native/cpp/CommonCpp/NativeModules/MessageStoreOperations.h b/native/cpp/CommonCpp/NativeModules/MessageStoreOperations.h
--- a/native/cpp/CommonCpp/NativeModules/MessageStoreOperations.h
+++ b/native/cpp/CommonCpp/NativeModules/MessageStoreOperations.h
@@ -210,4 +210,56 @@
std::vector<std::string> thread_ids;
};
+class RemoveMessageStoreLocalMessageInfosOperation : public DBOperationBase {
+public:
+ RemoveMessageStoreLocalMessageInfosOperation(
+ jsi::Runtime &rt,
+ const jsi::Object &payload)
+ : ids{} {
+ auto payload_ids = payload.getProperty(rt, "ids").asObject(rt).asArray(rt);
+ for (size_t idx = 0; idx < payload_ids.size(rt); idx++) {
+ this->ids.push_back(
+ payload_ids.getValueAtIndex(rt, idx).asString(rt).utf8(rt));
+ }
+ }
+
+ virtual void execute() override {
+ DatabaseManager::getQueryExecutor().removeMessageStoreLocalMessageInfos(
+ this->ids);
+ }
+
+private:
+ std::vector<std::string> ids;
+};
+
+class ReplaceMessageStoreLocalMessageInfoOperation : public DBOperationBase {
+public:
+ ReplaceMessageStoreLocalMessageInfoOperation(
+ jsi::Runtime &rt,
+ const jsi::Object &payload)
+ : localMessageInfo{} {
+ std::string id = payload.getProperty(rt, "id").asString(rt).utf8(rt);
+ std::string local_message_info =
+ payload.getProperty(rt, "localMessageInfo").asString(rt).utf8(rt);
+
+ this->localMessageInfo = LocalMessageInfo{id, local_message_info};
+ }
+
+ virtual void execute() override {
+ DatabaseManager::getQueryExecutor().replaceMessageStoreLocalMessageInfo(
+ this->localMessageInfo);
+ }
+
+private:
+ LocalMessageInfo localMessageInfo;
+};
+
+class RemoveAllMessageStoreLocalMessageInfosOperation : public DBOperationBase {
+public:
+ virtual void execute() override {
+ DatabaseManager::getQueryExecutor()
+ .removeAllMessageStoreLocalMessageInfos();
+ }
+};
+
} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.h
--- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.h
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.h
@@ -24,6 +24,10 @@
static OperationType REMOVE_MESSAGE_THREADS_OPERATION;
static OperationType REMOVE_ALL_MESSAGE_THREADS_OPERATION;
+ static OperationType REPLACE_MESSAGE_STORE_LOCAL_MESSAGE_INFO_OPERATION;
+ static OperationType REMOVE_MESSAGE_STORE_LOCAL_MESSAGE_INFOS_OPERATION;
+ static OperationType REMOVE_ALL_MESSAGE_STORE_LOCAL_MESSAGE_INFOS_OPERATION;
+
public:
MessageStore(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
@@ -38,6 +42,11 @@
jsi::Array parseDBMessageStoreThreads(
jsi::Runtime &rt,
std::shared_ptr<std::vector<MessageStoreThread>> threadsVectorPtr) const;
+
+ jsi::Array parseDBMessageStoreLocalMessageInfos(
+ jsi::Runtime &rt,
+ std::shared_ptr<std::vector<LocalMessageInfo>> localMessageInfosVectorPtr)
+ const;
};
} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.cpp
--- a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.cpp
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageStore.cpp
@@ -19,6 +19,14 @@
OperationType MessageStore::REMOVE_ALL_MESSAGE_THREADS_OPERATION =
"remove_all_threads";
+OperationType MessageStore::REPLACE_MESSAGE_STORE_LOCAL_MESSAGE_INFO_OPERATION =
+ "replace_local_message_info";
+OperationType MessageStore::REMOVE_MESSAGE_STORE_LOCAL_MESSAGE_INFOS_OPERATION =
+ "remove_local_message_infos";
+OperationType
+ MessageStore::REMOVE_ALL_MESSAGE_STORE_LOCAL_MESSAGE_INFOS_OPERATION =
+ "remove_all_local_message_infos";
+
MessageStore::MessageStore(
std::shared_ptr<facebook::react::CallInvoker> jsInvoker)
: BaseDataStore(jsInvoker) {
@@ -93,24 +101,25 @@
std::make_unique<RemoveAllMessageStoreThreadsOperation>());
continue;
}
+ if (op_type == REMOVE_ALL_MESSAGE_STORE_LOCAL_MESSAGE_INFOS_OPERATION) {
+ messageStoreOps.push_back(
+ std::make_unique<RemoveAllMessageStoreLocalMessageInfosOperation>());
+ continue;
+ }
auto payload_obj = op.getProperty(rt, "payload").asObject(rt);
if (op_type == REMOVE_OPERATION) {
messageStoreOps.push_back(
std::make_unique<RemoveMessagesOperation>(rt, payload_obj));
-
} else if (op_type == REMOVE_MSGS_FOR_THREADS_OPERATION) {
messageStoreOps.push_back(
std::make_unique<RemoveMessagesForThreadsOperation>(rt, payload_obj));
-
} else if (op_type == REPLACE_OPERATION) {
messageStoreOps.push_back(
std::make_unique<ReplaceMessageOperation>(rt, payload_obj));
-
} else if (op_type == REKEY_OPERATION) {
messageStoreOps.push_back(
std::make_unique<RekeyMessageOperation>(rt, payload_obj));
-
} else if (op_type == REPLACE_MESSAGE_THREADS_OPERATION) {
messageStoreOps.push_back(
std::make_unique<ReplaceMessageThreadsOperation>(rt, payload_obj));
@@ -118,6 +127,14 @@
messageStoreOps.push_back(
std::make_unique<RemoveMessageStoreThreadsOperation>(
rt, payload_obj));
+ } else if (op_type == REPLACE_MESSAGE_STORE_LOCAL_MESSAGE_INFO_OPERATION) {
+ messageStoreOps.push_back(
+ std::make_unique<ReplaceMessageStoreLocalMessageInfoOperation>(
+ rt, payload_obj));
+ } else if (op_type == REMOVE_MESSAGE_STORE_LOCAL_MESSAGE_INFOS_OPERATION) {
+ messageStoreOps.push_back(
+ std::make_unique<RemoveMessageStoreLocalMessageInfosOperation>(
+ rt, payload_obj));
} else {
throw std::runtime_error("unsupported operation: " + op_type);
}

File Metadata

Mime Type
text/plain
Expires
Fri, Dec 20, 6:40 AM (22 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2675723
Default Alt Text
D12249.id41158.diff (5 KB)

Event Timeline