Page MenuHomePhabricator

D12795.id42654.diff
No OneTemporary

D12795.id42654.diff

diff --git a/native/cpp/CommonCpp/DatabaseManagers/entities/MessageSearchResult.h b/native/cpp/CommonCpp/DatabaseManagers/entities/MessageSearchResult.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/DatabaseManagers/entities/MessageSearchResult.h
@@ -0,0 +1,28 @@
+#pragma once
+
+#include "SQLiteDataConverters.h"
+#include <sqlite3.h>
+#include <string>
+
+namespace comm {
+
+struct MessageSearchResult {
+ std::string original_message_id;
+ std::string message_id;
+ std::string processed_content;
+
+ static MessageSearchResult fromSQLResult(sqlite3_stmt *sqlRow, int idx) {
+ return MessageSearchResult{
+ getStringFromSQLRow(sqlRow, idx),
+ getStringFromSQLRow(sqlRow, idx + 1),
+ getStringFromSQLRow(sqlRow, idx + 2)};
+ }
+
+ int bindToSQL(sqlite3_stmt *sql, int idx) const {
+ bindStringToSQL(original_message_id, sql, idx);
+ bindStringToSQL(message_id, sql, idx + 1);
+ return bindStringToSQL(processed_content, sql, idx + 2);
+ }
+};
+
+} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/CMakeLists.txt b/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
--- a/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
+++ b/native/cpp/CommonCpp/NativeModules/CMakeLists.txt
@@ -25,6 +25,7 @@
"AuxUserStoreOperations.h"
"ThreadActivityStoreOperations.h"
"EntryStoreOperations.h"
+ "MessageSearchStoreOperations.h"
)
set(NATIVE_SRCS
@@ -93,6 +94,7 @@
${_data_stores_path}/AuxUserStore.h
${_data_stores_path}/ThreadActivityStore.h
${_data_stores_path}/EntryStore.h
+ ${_data_stores_path}/MessageSearchStore.h
)
set(DATA_STORES_SRCS
${_data_stores_path}/DraftStore.cpp
@@ -107,6 +109,7 @@
${_data_stores_path}/AuxUserStore.cpp
${_data_stores_path}/ThreadActivityStore.cpp
${_data_stores_path}/EntryStore.cpp
+ ${_data_stores_path}/MessageSearchStore.cpp
)
set(_backup_op_path ./PersistentStorageUtilities/BackupOperationsUtilities)
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageSearchStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageSearchStore.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageSearchStore.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include "../../../DatabaseManagers/entities/MessageSearchResult.h"
+#include "../../DBOperationBase.h"
+#include "../../MessageSearchStoreOperations.h"
+#include "BaseDataStore.h"
+
+#include <jsi/jsi.h>
+
+namespace comm {
+
+class MessageSearchStore
+ : public BaseDataStore<DBOperationBase, MessageSearchResult> {
+private:
+ static OperationType UPDATE_OPERATION;
+
+public:
+ MessageSearchStore(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
+
+ std::vector<std::unique_ptr<DBOperationBase>> createOperations(
+ jsi::Runtime &rt,
+ const jsi::Array &operations) const override;
+
+ jsi::Array parseDBDataStore(
+ jsi::Runtime &rt,
+ std::shared_ptr<std::vector<MessageSearchResult>> dataVectorPtr)
+ const override;
+};
+
+} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageSearchStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageSearchStore.cpp
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/MessageSearchStore.cpp
@@ -0,0 +1,44 @@
+#include "MessageSearchStore.h"
+
+#include "../../DBOperationBase.h"
+#include <ReactCommon/TurboModuleUtils.h>
+#include <jsi/jsi.h>
+
+namespace comm {
+
+OperationType MessageSearchStore::UPDATE_OPERATION = "update_search_messages";
+
+MessageSearchStore::MessageSearchStore(
+ std::shared_ptr<facebook::react::CallInvoker> jsInvoker)
+ : BaseDataStore(jsInvoker) {
+}
+
+jsi::Array MessageSearchStore::parseDBDataStore(
+ jsi::Runtime &rt,
+ std::shared_ptr<std::vector<MessageSearchResult>> vectorPtr) const {
+ jsi::Array jsiSearchMessages = jsi::Array(rt, 0);
+
+ return jsiSearchMessages;
+}
+
+std::vector<std::unique_ptr<DBOperationBase>>
+MessageSearchStore::createOperations(
+ jsi::Runtime &rt,
+ const jsi::Array &operations) const {
+ std::vector<std::unique_ptr<DBOperationBase>> messageSearchStoreOps;
+ for (auto idx = 0; idx < operations.size(rt); idx++) {
+ auto op = operations.getValueAtIndex(rt, idx).asObject(rt);
+ auto op_type = op.getProperty(rt, "type").asString(rt).utf8(rt);
+
+ auto payload_obj = op.getProperty(rt, "payload").asObject(rt);
+ if (op_type == UPDATE_OPERATION) {
+ messageSearchStoreOps.push_back(
+ std::make_unique<UpdateMessageSearchIndexOperation>(rt, payload_obj));
+ } else {
+ throw std::runtime_error("unsupported operation: " + op_type);
+ }
+ }
+ return messageSearchStoreOps;
+}
+
+} // namespace comm
diff --git a/native/ios/Comm.xcodeproj/project.pbxproj b/native/ios/Comm.xcodeproj/project.pbxproj
--- a/native/ios/Comm.xcodeproj/project.pbxproj
+++ b/native/ios/Comm.xcodeproj/project.pbxproj
@@ -44,6 +44,7 @@
7FBB2A7829E945C2002C6493 /* CommUtilsModule.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FBB2A7329E944FD002C6493 /* CommUtilsModule.cpp */; };
7FBB2A7B29EEA2A4002C6493 /* Base64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FBB2A7A29EEA2A4002C6493 /* Base64.cpp */; };
7FE4D9F5291DFE9300667BF6 /* commJSI-generated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7FE4D9F4291DFE9300667BF6 /* commJSI-generated.cpp */; };
+ 816D2D5A2C480E60001C0B67 /* MessageSearchStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 816D2D582C480E60001C0B67 /* MessageSearchStore.cpp */; };
8B38121629CE5742000C52E9 /* RustPromiseManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8B38121529CE5742000C52E9 /* RustPromiseManager.cpp */; };
8B652FA6295EAA5B009F8163 /* RustCallback.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8B652FA5295EAA5B009F8163 /* RustCallback.cpp */; };
8B99BAAC28D50F3000EB5ADB /* libnative_rust_library.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8B99BAAB28D50F3000EB5ADB /* libnative_rust_library.a */; };
@@ -222,6 +223,9 @@
7FCFD8BD1E81B8DF00629B0E /* Comm.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; name = Comm.entitlements; path = Comm/Comm.entitlements; sourceTree = "<group>"; };
7FE4D9F3291DFE9300667BF6 /* commJSI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = commJSI.h; sourceTree = "<group>"; };
7FE4D9F4291DFE9300667BF6 /* commJSI-generated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "commJSI-generated.cpp"; sourceTree = "<group>"; };
+ 816D2D582C480E60001C0B67 /* MessageSearchStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MessageSearchStore.cpp; path = PersistentStorageUtilities/DataStores/MessageSearchStore.cpp; sourceTree = "<group>"; };
+ 816D2D592C480E60001C0B67 /* MessageSearchStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MessageSearchStore.h; path = PersistentStorageUtilities/DataStores/MessageSearchStore.h; sourceTree = "<group>"; };
+ 816D2D5B2C480E9E001C0B67 /* MessageSearchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageSearchResult.h; sourceTree = "<group>"; };
891D1495EE1F375F3AF6C7ED /* Pods-NotificationService.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-NotificationService.debug.xcconfig"; path = "Target Support Files/Pods-NotificationService/Pods-NotificationService.debug.xcconfig"; sourceTree = "<group>"; };
8B38121529CE5742000C52E9 /* RustPromiseManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RustPromiseManager.cpp; sourceTree = "<group>"; };
8B652FA1295EA6B8009F8163 /* RustPromiseManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RustPromiseManager.h; sourceTree = "<group>"; };
@@ -542,6 +546,7 @@
71BE84442636A944002849D2 /* entities */ = {
isa = PBXGroup;
children = (
+ 816D2D5B2C480E9E001C0B67 /* MessageSearchResult.h */,
CB01F0C32B67F3970089E1F9 /* SQLiteStatementWrapper.cpp */,
CB01F0C12B67EF470089E1F9 /* SQLiteDataConverters.cpp */,
CB01F0C02B67CDC20089E1F9 /* SQLiteDataConverters.h */,
@@ -676,6 +681,8 @@
8EA59BD02A6E786200EB4F53 /* DataStores */ = {
isa = PBXGroup;
children = (
+ 816D2D582C480E60001C0B67 /* MessageSearchStore.cpp */,
+ 816D2D592C480E60001C0B67 /* MessageSearchStore.h */,
CBAB63882BFCB087003B089F /* EntryStore.cpp */,
CBAB63892BFCB087003B089F /* EntryStore.h */,
34FF25B82BB753B30075EC40 /* AuxUserStore.h */,
@@ -1224,6 +1231,7 @@
7FBB2A7B29EEA2A4002C6493 /* Base64.cpp in Sources */,
CB38F2B1286C6C870010535C /* MessageOperationsUtilities.cpp in Sources */,
DFD5E7862B052B1400C32B6A /* RustAESCrypto.cpp in Sources */,
+ 816D2D5A2C480E60001C0B67 /* MessageSearchStore.cpp in Sources */,
8EF775712A751B780046A385 /* ReportStore.cpp in Sources */,
34329B442B9EC7EC00233438 /* IntegrityStore.cpp in Sources */,
71CA4A64262DA8E500835C89 /* Logger.mm in Sources */,

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 25, 4:04 AM (21 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578298
Default Alt Text
D12795.id42654.diff (9 KB)

Event Timeline