Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3399429
D11584.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
18 KB
Referenced Files
None
Subscribers
None
D11584.diff
View Options
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
@@ -23,6 +23,7 @@
"IntegrityStoreOperations.h"
"SyncedMetadataStoreOperations.h"
"AuxUserStoreOperations.h"
+ "ThreadActivityStoreOperations.h"
)
set(NATIVE_SRCS
@@ -89,6 +90,7 @@
${_data_stores_path}/IntegrityStore.h
${_data_stores_path}/SyncedMetadataStore.h
${_data_stores_path}/AuxUserStore.h
+ ${_data_stores_path}/ThreadActivityStore.h
)
set(DATA_STORES_SRCS
${_data_stores_path}/DraftStore.cpp
@@ -101,6 +103,7 @@
${_data_stores_path}/IntegrityStore.cpp
${_data_stores_path}/SyncedMetadataStore.cpp
${_data_stores_path}/AuxUserStore.cpp
+ ${_data_stores_path}/ThreadActivityStore.cpp
)
set(_backup_op_path ./PersistentStorageUtilities/BackupOperationsUtilities)
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
@@ -13,6 +13,7 @@
#include "PersistentStorageUtilities/DataStores/MessageStore.h"
#include "PersistentStorageUtilities/DataStores/ReportStore.h"
#include "PersistentStorageUtilities/DataStores/SyncedMetadataStore.h"
+#include "PersistentStorageUtilities/DataStores/ThreadActivityStore.h"
#include "PersistentStorageUtilities/DataStores/ThreadStore.h"
#include "PersistentStorageUtilities/DataStores/UserStore.h"
#include <ReactCommon/TurboModuleUtils.h>
@@ -43,6 +44,7 @@
IntegrityStore integrityStore;
SyncedMetadataStore syncedMetadataStore;
AuxUserStore auxUserStore;
+ ThreadActivityStore threadActivityStore;
void
persistCryptoModules(bool persistContentModule, bool persistNotifsModule);
@@ -93,6 +95,9 @@
virtual jsi::Value processAuxUserStoreOperations(
jsi::Runtime &rt,
jsi::Array operations) override;
+ virtual jsi::Value processThreadActivityStoreOperations(
+ jsi::Runtime &rt,
+ jsi::Array operations) override;
virtual jsi::Value initializeCryptoAccount(jsi::Runtime &rt) override;
virtual jsi::Value getUserPublicKey(jsi::Runtime &rt) override;
virtual jsi::Value
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
@@ -385,6 +385,13 @@
return this->auxUserStore.processStoreOperations(rt, std::move(operations));
}
+jsi::Value CommCoreModule::processThreadActivityStoreOperations(
+ jsi::Runtime &rt,
+ jsi::Array operations) {
+ return this->threadActivityStore.processStoreOperations(
+ rt, std::move(operations));
+}
+
void CommCoreModule::terminate(jsi::Runtime &rt) {
TerminateApp::terminate();
}
@@ -1380,7 +1387,8 @@
communityStore(jsInvoker),
integrityStore(jsInvoker),
syncedMetadataStore(jsInvoker),
- auxUserStore(jsInvoker) {
+ auxUserStore(jsInvoker),
+ threadActivityStore(jsInvoker) {
GlobalDBSingleton::instance.enableMultithreading();
}
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.h b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.h
@@ -0,0 +1,32 @@
+#pragma once
+
+#include "../../../DatabaseManagers/entities/ThreadActivityEntry.h"
+#include "BaseDataStore.h"
+#include "ThreadActivityStoreOperations.h"
+
+#include <jsi/jsi.h>
+
+namespace comm {
+
+class ThreadActivityStore : public BaseDataStore<
+ ThreadActivityStoreOperationBase,
+ ThreadActivityEntry> {
+private:
+ static OperationType REMOVE_OPERATION;
+ static OperationType REMOVE_ALL_OPERATION;
+ static OperationType REPLACE_OPERATION;
+
+public:
+ ThreadActivityStore(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
+
+ std::vector<std::unique_ptr<ThreadActivityStoreOperationBase>>
+ createOperations(jsi::Runtime &rt, const jsi::Array &operations)
+ const override;
+
+ jsi::Array parseDBDataStore(
+ jsi::Runtime &rt,
+ std::shared_ptr<std::vector<ThreadActivityEntry>> dataVectorPtr)
+ const override;
+};
+
+} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.cpp b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.cpp
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/PersistentStorageUtilities/DataStores/ThreadActivityStore.cpp
@@ -0,0 +1,74 @@
+#include "ThreadActivityStore.h"
+
+#include <ReactCommon/TurboModuleUtils.h>
+#include <jsi/jsi.h>
+
+namespace comm {
+
+OperationType ThreadActivityStore::REPLACE_OPERATION =
+ "replace_thread_activity_entry";
+OperationType ThreadActivityStore::REMOVE_OPERATION =
+ "remove_thread_activity_entries";
+OperationType ThreadActivityStore::REMOVE_ALL_OPERATION =
+ "remove_all_thread_activity_entries";
+
+ThreadActivityStore::ThreadActivityStore(
+ std::shared_ptr<facebook::react::CallInvoker> jsInvoker)
+ : BaseDataStore(jsInvoker) {
+}
+
+jsi::Array ThreadActivityStore::parseDBDataStore(
+ jsi::Runtime &rt,
+ std::shared_ptr<std::vector<ThreadActivityEntry>> threadActivityVectorPtr)
+ const {
+ jsi::Array jsiThreadActivityEntries = jsi::Array(rt, 0);
+ return jsiThreadActivityEntries;
+}
+
+std::vector<std::unique_ptr<ThreadActivityStoreOperationBase>>
+ThreadActivityStore::createOperations(
+ jsi::Runtime &rt,
+ const jsi::Array &operations) const {
+ std::vector<std::unique_ptr<ThreadActivityStoreOperationBase>>
+ threadActivityStoreOps;
+
+ for (size_t idx = 0; idx < operations.size(rt); idx++) {
+ jsi::Object op = operations.getValueAtIndex(rt, idx).asObject(rt);
+ std::string opType = op.getProperty(rt, "type").asString(rt).utf8(rt);
+
+ if (opType == REMOVE_OPERATION) {
+ std::vector<std::string> threadIDsToRemove;
+ jsi::Object payloadObj = op.getProperty(rt, "payload").asObject(rt);
+ jsi::Array threadIDs =
+ payloadObj.getProperty(rt, "ids").asObject(rt).asArray(rt);
+ for (int threadIdx = 0; threadIdx < threadIDs.size(rt); threadIdx++) {
+ threadIDsToRemove.push_back(
+ threadIDs.getValueAtIndex(rt, threadIdx).asString(rt).utf8(rt));
+ }
+ threadActivityStoreOps.push_back(
+ std::make_unique<RemoveThreadActivityEntriesOperation>(
+ std::move(threadIDsToRemove)));
+ } else if (opType == REMOVE_ALL_OPERATION) {
+ threadActivityStoreOps.push_back(
+ std::make_unique<RemoveAllThreadActivityEntriesOperation>());
+ } else if (opType == REPLACE_OPERATION) {
+ jsi::Object payloadObj = op.getProperty(rt, "payload").asObject(rt);
+ std::string id = payloadObj.getProperty(rt, "id").asString(rt).utf8(rt);
+ std::string thread_activity_store_entry =
+ payloadObj.getProperty(rt, "threadActivityStoreEntry")
+ .asString(rt)
+ .utf8(rt);
+
+ ThreadActivityEntry threadActivityEntry{id, thread_activity_store_entry};
+
+ threadActivityStoreOps.push_back(
+ std::make_unique<ReplaceThreadActivityEntryOperation>(
+ std::move(threadActivityEntry)));
+ } else {
+ throw std::runtime_error("unsupported operation: " + opType);
+ }
+ };
+ return threadActivityStoreOps;
+}
+
+} // namespace comm
diff --git a/native/cpp/CommonCpp/NativeModules/ThreadActivityStoreOperations.h b/native/cpp/CommonCpp/NativeModules/ThreadActivityStoreOperations.h
new file mode 100644
--- /dev/null
+++ b/native/cpp/CommonCpp/NativeModules/ThreadActivityStoreOperations.h
@@ -0,0 +1,53 @@
+#pragma once
+
+#include "../DatabaseManagers/entities/ThreadActivityEntry.h"
+#include "DatabaseManager.h"
+#include <vector>
+
+namespace comm {
+class ThreadActivityStoreOperationBase {
+public:
+ virtual void execute() = 0;
+ virtual ~ThreadActivityStoreOperationBase(){};
+};
+
+class RemoveThreadActivityEntriesOperation
+ : public ThreadActivityStoreOperationBase {
+public:
+ RemoveThreadActivityEntriesOperation(std::vector<std::string> ids)
+ : ids{ids} {
+ }
+
+ virtual void execute() override {
+ DatabaseManager::getQueryExecutor().removeThreadActivityEntries(this->ids);
+ }
+
+private:
+ std::vector<std::string> ids;
+};
+
+class ReplaceThreadActivityEntryOperation
+ : public ThreadActivityStoreOperationBase {
+public:
+ ReplaceThreadActivityEntryOperation(ThreadActivityEntry &&threadActivityEntry)
+ : threadActivityEntry{std::move(threadActivityEntry)} {
+ }
+
+ virtual void execute() override {
+ DatabaseManager::getQueryExecutor().replaceThreadActivityEntry(
+ this->threadActivityEntry);
+ }
+
+private:
+ ThreadActivityEntry threadActivityEntry;
+};
+
+class RemoveAllThreadActivityEntriesOperation
+ : public ThreadActivityStoreOperationBase {
+public:
+ virtual void execute() override {
+ DatabaseManager::getQueryExecutor().removeAllThreadActivityEntries();
+ }
+};
+
+} // namespace comm
diff --git a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
--- a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
@@ -75,6 +75,9 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processAuxUserStoreOperations(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->processAuxUserStoreOperations(rt, args[0].asObject(rt).asArray(rt));
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processThreadActivityStoreOperations(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->processThreadActivityStoreOperations(rt, args[0].asObject(rt).asArray(rt));
+}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_initializeCryptoAccount(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->initializeCryptoAccount(rt);
}
@@ -213,6 +216,7 @@
methodMap_["processIntegrityStoreOperations"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processIntegrityStoreOperations};
methodMap_["processSyncedMetadataStoreOperations"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processSyncedMetadataStoreOperations};
methodMap_["processAuxUserStoreOperations"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processAuxUserStoreOperations};
+ methodMap_["processThreadActivityStoreOperations"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_processThreadActivityStoreOperations};
methodMap_["initializeCryptoAccount"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_initializeCryptoAccount};
methodMap_["getUserPublicKey"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getUserPublicKey};
methodMap_["getOneTimeKeys"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getOneTimeKeys};
diff --git a/native/cpp/CommonCpp/_generated/commJSI.h b/native/cpp/CommonCpp/_generated/commJSI.h
--- a/native/cpp/CommonCpp/_generated/commJSI.h
+++ b/native/cpp/CommonCpp/_generated/commJSI.h
@@ -40,6 +40,7 @@
virtual jsi::Value processIntegrityStoreOperations(jsi::Runtime &rt, jsi::Array operations) = 0;
virtual jsi::Value processSyncedMetadataStoreOperations(jsi::Runtime &rt, jsi::Array operations) = 0;
virtual jsi::Value processAuxUserStoreOperations(jsi::Runtime &rt, jsi::Array operations) = 0;
+ virtual jsi::Value processThreadActivityStoreOperations(jsi::Runtime &rt, jsi::Array operations) = 0;
virtual jsi::Value initializeCryptoAccount(jsi::Runtime &rt) = 0;
virtual jsi::Value getUserPublicKey(jsi::Runtime &rt) = 0;
virtual jsi::Value getOneTimeKeys(jsi::Runtime &rt, double oneTimeKeysAmount) = 0;
@@ -258,6 +259,14 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::processAuxUserStoreOperations, jsInvoker_, instance_, std::move(operations));
}
+ jsi::Value processThreadActivityStoreOperations(jsi::Runtime &rt, jsi::Array operations) override {
+ static_assert(
+ bridging::getParameterCount(&T::processThreadActivityStoreOperations) == 2,
+ "Expected processThreadActivityStoreOperations(...) to have 2 parameters");
+
+ return bridging::callFromJs<jsi::Value>(
+ rt, &T::processThreadActivityStoreOperations, jsInvoker_, instance_, std::move(operations));
+ }
jsi::Value initializeCryptoAccount(jsi::Runtime &rt) override {
static_assert(
bridging::getParameterCount(&T::initializeCryptoAccount) == 1,
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
@@ -13,6 +13,7 @@
1F537ACC7B60DC049C0ECFA7 /* ExpoModulesProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 769A87FB41BCE3FEF97FD59A /* ExpoModulesProvider.swift */; };
34055C152BAD31AC0008E713 /* SyncedMetadataStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34055C142BAD31AC0008E713 /* SyncedMetadataStore.cpp */; };
34329B442B9EC7EC00233438 /* IntegrityStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34329B3F2B9EBFCE00233438 /* IntegrityStore.cpp */; };
+ 34BE127D2BC3F78C00CCAD11 /* ThreadActivityStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34BE127C2BC3F78C00CCAD11 /* ThreadActivityStore.cpp */; };
34FF25BA2BB757870075EC40 /* AuxUserStore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34FF25B92BB757860075EC40 /* AuxUserStore.cpp */; };
71142A7726C2650B0039DCBD /* CommSecureStoreIOSWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 71142A7626C2650A0039DCBD /* CommSecureStoreIOSWrapper.mm */; };
711B408425DA97F9005F8F06 /* dummy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7F26E81B24440D87004049C6 /* dummy.swift */; };
@@ -150,6 +151,9 @@
34329B3F2B9EBFCE00233438 /* IntegrityStore.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = IntegrityStore.cpp; path = PersistentStorageUtilities/DataStores/IntegrityStore.cpp; sourceTree = "<group>"; };
34329B402B9EBFCE00233438 /* IntegrityStore.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = IntegrityStore.h; path = PersistentStorageUtilities/DataStores/IntegrityStore.h; sourceTree = "<group>"; };
34329B452B9EC96200233438 /* IntegrityThreadHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntegrityThreadHash.h; sourceTree = "<group>"; };
+ 34BE12762BC3F3D100CCAD11 /* ThreadActivityStoreOperations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ThreadActivityStoreOperations.h; sourceTree = "<group>"; };
+ 34BE127B2BC3F78B00CCAD11 /* ThreadActivityStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ThreadActivityStore.h; path = PersistentStorageUtilities/DataStores/ThreadActivityStore.h; sourceTree = "<group>"; };
+ 34BE127C2BC3F78C00CCAD11 /* ThreadActivityStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ThreadActivityStore.cpp; path = PersistentStorageUtilities/DataStores/ThreadActivityStore.cpp; sourceTree = "<group>"; };
34FF25A62BB738DC0075EC40 /* AuxUserStoreOperations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AuxUserStoreOperations.h; sourceTree = "<group>"; };
34FF25B82BB753B30075EC40 /* AuxUserStore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AuxUserStore.h; path = PersistentStorageUtilities/DataStores/AuxUserStore.h; sourceTree = "<group>"; };
34FF25B92BB757860075EC40 /* AuxUserStore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AuxUserStore.cpp; path = PersistentStorageUtilities/DataStores/AuxUserStore.cpp; sourceTree = "<group>"; };
@@ -505,6 +509,7 @@
B7055C6B26E477CF00BE0548 /* MessageStoreOperations.h */,
B7906F692720905A009BBBF5 /* ThreadStoreOperations.h */,
34FF25A62BB738DC0075EC40 /* AuxUserStoreOperations.h */,
+ 34BE12762BC3F3D100CCAD11 /* ThreadActivityStoreOperations.h */,
);
path = NativeModules;
sourceTree = "<group>";
@@ -683,6 +688,8 @@
8EA59BD32A6E8CB700EB4F53 /* BaseDataStore.h */,
34055C142BAD31AC0008E713 /* SyncedMetadataStore.cpp */,
34055C132BAD31AB0008E713 /* SyncedMetadataStore.h */,
+ 34BE127C2BC3F78C00CCAD11 /* ThreadActivityStore.cpp */,
+ 34BE127B2BC3F78B00CCAD11 /* ThreadActivityStore.h */,
);
name = DataStores;
sourceTree = "<group>";
@@ -1168,6 +1175,7 @@
34FF25BA2BB757870075EC40 /* AuxUserStore.cpp in Sources */,
CB7EF17E295C674300B17035 /* CommIOSNotifications.mm in Sources */,
CB7EF180295C674300B17035 /* CommIOSNotificationsBridgeQueue.mm in Sources */,
+ 34BE127D2BC3F78C00CCAD11 /* ThreadActivityStore.cpp in Sources */,
7F0C6E31291C4468002AA2D9 /* ExpoModulesProvider.swift in Sources */,
8EF775682A74032C0046A385 /* CommRustModule.cpp in Sources */,
34055C152BAD31AC0008E713 /* SyncedMetadataStore.cpp in Sources */,
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -12,6 +12,7 @@
import type { ClientDBMessageStoreOperation } from 'lib/ops/message-store-ops.js';
import type { ClientDBReportStoreOperation } from 'lib/ops/report-store-ops.js';
import type { ClientDBSyncedMetadataStoreOperation } from 'lib/ops/synced-metadata-store-ops.js';
+import type { ClientDBThreadActivityStoreOperation } from 'lib/ops/thread-activity-store-ops.js';
import type { ClientDBThreadStoreOperation } from 'lib/ops/thread-store-ops.js';
import type { ClientDBUserStoreOperation } from 'lib/ops/user-store-ops';
import type {
@@ -79,6 +80,9 @@
+processAuxUserStoreOperations: (
operations: $ReadOnlyArray<ClientDBAuxUserStoreOperation>,
) => Promise<void>;
+ +processThreadActivityStoreOperations: (
+ operations: $ReadOnlyArray<ClientDBThreadActivityStoreOperation>,
+ ) => Promise<void>;
+initializeCryptoAccount: () => Promise<string>;
+getUserPublicKey: () => Promise<ClientPublicKeys>;
+getOneTimeKeys: (oneTimeKeysAmount: number) => Promise<OneTimeKeysResult>;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 3, 3:16 AM (21 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2609990
Default Alt Text
D11584.diff (18 KB)
Attached To
Mode
D11584: [sqlite/native] Make C++ thread activity sqlite ops available to native
Attached
Detach File
Event Timeline
Log In to Comment