Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3348581
D12130.id40421.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Referenced Files
None
Subscribers
None
D12130.id40421.diff
View Options
diff --git a/lib/types/store-ops-types.js b/lib/types/store-ops-types.js
--- a/lib/types/store-ops-types.js
+++ b/lib/types/store-ops-types.js
@@ -14,6 +14,7 @@
ClientDBThreadMessageInfo,
} from './message-types.js';
import type { ClientReportCreationRequest } from './report-types.js';
+import type { OutboundP2PMessage } from './sqlite-types.js';
import type { SyncedMetadata } from './synced-metadata-types.js';
import type { ThreadActivityStore } from './thread-activity-types.js';
import type { ClientDBThreadInfo, ThreadStore } from './thread-types.js';
@@ -78,6 +79,7 @@
+syncedMetadataStoreOperations?: $ReadOnlyArray<ClientDBSyncedMetadataStoreOperation>,
+auxUserStoreOperations?: $ReadOnlyArray<AuxUserStoreOperation>,
+threadActivityStoreOperations?: $ReadOnlyArray<ThreadActivityStoreOperation>,
+ +outboundP2PMessages?: $ReadOnlyArray<OutboundP2PMessage>,
};
export type ClientDBStoreOperations = {
@@ -92,6 +94,7 @@
+syncedMetadataStoreOperations?: $ReadOnlyArray<ClientDBSyncedMetadataStoreOperation>,
+auxUserStoreOperations?: $ReadOnlyArray<ClientDBAuxUserStoreOperation>,
+threadActivityStoreOperations?: $ReadOnlyArray<ClientDBThreadActivityStoreOperation>,
+ +outboundP2PMessages?: $ReadOnlyArray<OutboundP2PMessage>,
};
export type ClientDBStore = {
diff --git a/native/cpp/CommonCpp/DatabaseManagers/entities/OutboundP2PMessage.h b/native/cpp/CommonCpp/DatabaseManagers/entities/OutboundP2PMessage.h
--- a/native/cpp/CommonCpp/DatabaseManagers/entities/OutboundP2PMessage.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/entities/OutboundP2PMessage.h
@@ -51,6 +51,23 @@
OutboundP2PMessage() = default;
+ OutboundP2PMessage(
+ const std::string &message_id,
+ const std::string &device_id,
+ const std::string &user_id,
+ const std::string ×tamp,
+ const std::string &plaintext,
+ const std::string &ciphertext,
+ const std::string &status)
+ : message_id(message_id),
+ device_id(device_id),
+ user_id(user_id),
+ timestamp(timestamp),
+ plaintext(plaintext),
+ ciphertext(ciphertext),
+ status(status) {
+ }
+
OutboundP2PMessage(const SQLiteOutboundP2PMessage &msg) {
message_id = msg.message_id;
device_id = msg.device_id;
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
@@ -427,6 +427,47 @@
createOperationsError = e.what();
}
+
+ std::vector<OutboundP2PMessage> messages;
+ try {
+ auto messagesJSIObj = operations.getProperty(rt, "outboundP2PMessages");
+
+ if (messagesJSIObj.isObject()) {
+ auto messagesJSI = messagesJSIObj.asObject(rt).asArray(rt);
+ for (size_t idx = 0; idx < messagesJSI.size(rt); idx++) {
+ jsi::Object msgObj = messagesJSI.getValueAtIndex(rt, idx).asObject(rt);
+
+ std::string messageID =
+ msgObj.getProperty(rt, "messageID").asString(rt).utf8(rt);
+ std::string deviceID =
+ msgObj.getProperty(rt, "deviceID").asString(rt).utf8(rt);
+ std::string userID =
+ msgObj.getProperty(rt, "userID").asString(rt).utf8(rt);
+ std::string timestamp =
+ msgObj.getProperty(rt, "timestamp").asString(rt).utf8(rt);
+ std::string plaintext =
+ msgObj.getProperty(rt, "plaintext").asString(rt).utf8(rt);
+ std::string ciphertext =
+ msgObj.getProperty(rt, "ciphertext").asString(rt).utf8(rt);
+ std::string status =
+ msgObj.getProperty(rt, "status").asString(rt).utf8(rt);
+
+ OutboundP2PMessage outboundMessage{
+ messageID,
+ deviceID,
+ userID,
+ timestamp,
+ plaintext,
+ ciphertext,
+ status};
+ messages.push_back(outboundMessage);
+ }
+ }
+
+ } catch (std::runtime_error &e) {
+ createOperationsError = e.what();
+ }
+
return facebook::react::createPromiseAsJSIValue(
rt,
[=](jsi::Runtime &innerRt,
@@ -440,6 +481,10 @@
for (const auto &operation : *storeOpsPtr) {
operation->execute();
}
+ if (messages.size() > 0) {
+ DatabaseManager::getQueryExecutor().addOutboundP2PMessages(
+ messages);
+ }
DatabaseManager::getQueryExecutor().captureBackupLogs();
DatabaseManager::getQueryExecutor().commitTransaction();
} catch (std::system_error &e) {
diff --git a/native/redux/redux-utils.js b/native/redux/redux-utils.js
--- a/native/redux/redux-utils.js
+++ b/native/redux/redux-utils.js
@@ -44,6 +44,7 @@
syncedMetadataStoreOperations,
auxUserStoreOperations,
threadActivityStoreOperations,
+ outboundP2PMessages,
} = storeOperations;
const convertedThreadStoreOperations =
@@ -95,6 +96,7 @@
syncedMetadataStoreOperations: convertedSyncedMetadataStoreOperations,
auxUserStoreOperations: convertedAuxUserStoreOperations,
threadActivityStoreOperations: convertedThreadActivityStoreOperations,
+ outboundP2PMessages,
};
if (values(dbOps).some(ops => ops && ops.length > 0)) {
promises.push(commCoreModule.processDBStoreOperations(dbOps));
diff --git a/web/shared-worker/utils/store.js b/web/shared-worker/utils/store.js
--- a/web/shared-worker/utils/store.js
+++ b/web/shared-worker/utils/store.js
@@ -154,6 +154,7 @@
userStoreOperations,
messageStoreOperations,
threadActivityStoreOperations,
+ outboundP2PMessages,
} = storeOperations;
const canUseDatabase = canUseDatabaseOnWeb(userID);
@@ -220,6 +221,7 @@
userStoreOperations: convertedUserStoreOperations,
messageStoreOperations: convertedMessageStoreOperations,
threadActivityStoreOperations: convertedThreadActivityStoreOperations,
+ outboundP2PMessages,
},
});
} catch (e) {
diff --git a/web/shared-worker/worker/process-operations.js b/web/shared-worker/worker/process-operations.js
--- a/web/shared-worker/worker/process-operations.js
+++ b/web/shared-worker/worker/process-operations.js
@@ -362,6 +362,7 @@
userStoreOperations,
messageStoreOperations,
threadActivityStoreOperations,
+ outboundP2PMessages,
} = storeOperations;
try {
@@ -449,6 +450,9 @@
module,
);
}
+ if (outboundP2PMessages && outboundP2PMessages.length > 0) {
+ sqliteQueryExecutor.addOutboundP2PMessages(outboundP2PMessages);
+ }
sqliteQueryExecutor.commitTransaction();
} catch (e) {
sqliteQueryExecutor.rollbackTransaction();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 3:16 PM (19 h, 33 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571335
Default Alt Text
D12130.id40421.diff (6 KB)
Attached To
Mode
D12130: [web][native] persist Outbound P2P messages when processing store ops
Attached
Detach File
Event Timeline
Log In to Comment