Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3525473
D12046.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
31 KB
Referenced Files
None
Subscribers
None
D12046.id.diff
View Options
diff --git a/lib/handlers/db-ops-handler.react.js b/lib/handlers/db-ops-handler.react.js
--- a/lib/handlers/db-ops-handler.react.js
+++ b/lib/handlers/db-ops-handler.react.js
@@ -50,7 +50,7 @@
deviceID: senderDeviceID,
payload: JSON.stringify(message),
});
- await sqliteAPI.removeReceivedMessagesToDevice([messageID]);
+ await sqliteAPI.removeInboundP2PMessages([messageID]);
}
})();
}, [queueFront, dispatch, processDBStoreOperations, sendMessage, sqliteAPI]);
diff --git a/lib/types/sqlite-types.js b/lib/types/sqlite-types.js
--- a/lib/types/sqlite-types.js
+++ b/lib/types/sqlite-types.js
@@ -2,7 +2,7 @@
import type { StoreOperations } from './store-ops-types.js';
-export type ReceivedMessageToDevice = {
+export type InboundP2PMessage = {
+messageID: string,
+senderDeviceID: string,
+plaintext: string,
@@ -11,12 +11,10 @@
export type SQLiteAPI = {
// read operations
- +getAllReceivedMessageToDevice: () => Promise<ReceivedMessageToDevice[]>,
+ +getAllInboundP2PMessage: () => Promise<InboundP2PMessage[]>,
// write operations
- +removeReceivedMessagesToDevice: (
- ids: $ReadOnlyArray<string>,
- ) => Promise<void>,
+ +removeInboundP2PMessages: (ids: $ReadOnlyArray<string>) => Promise<void>,
+processDBStoreOperations: (
operations: StoreOperations,
diff --git a/lib/utils/__mocks__/config.js b/lib/utils/__mocks__/config.js
--- a/lib/utils/__mocks__/config.js
+++ b/lib/utils/__mocks__/config.js
@@ -27,8 +27,8 @@
verifyMessage: jest.fn(),
},
sqliteAPI: {
- getAllReceivedMessageToDevice: jest.fn(),
- removeReceivedMessagesToDevice: jest.fn(),
+ getAllInboundP2PMessage: jest.fn(),
+ removeInboundP2PMessages: jest.fn(),
processDBStoreOperations: jest.fn(),
},
});
diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
@@ -4,6 +4,7 @@
#include "entities/AuxUserInfo.h"
#include "entities/CommunityInfo.h"
#include "entities/Draft.h"
+#include "entities/InboundP2PMessage.h"
#include "entities/IntegrityThreadHash.h"
#include "entities/KeyserverInfo.h"
#include "entities/Message.h"
@@ -12,7 +13,6 @@
#include "entities/OlmPersistAccount.h"
#include "entities/OlmPersistSession.h"
#include "entities/PersistItem.h"
-#include "entities/ReceivedMessageToDevice.h"
#include "entities/Report.h"
#include "entities/SyncedMetadataEntry.h"
#include "entities/Thread.h"
@@ -143,12 +143,10 @@
const ClientMessageToDevice &lastConfirmedMessage) const = 0;
virtual void
removeAllMessagesForDevice(const std::string &deviceID) const = 0;
+ virtual void addInboundP2PMessage(InboundP2PMessage message) const = 0;
+ virtual std::vector<InboundP2PMessage> getAllInboundP2PMessage() const = 0;
virtual void
- addReceivedMessageToDevice(ReceivedMessageToDevice message) const = 0;
- virtual std::vector<ReceivedMessageToDevice>
- getAllReceivedMessageToDevice() const = 0;
- virtual void
- removeReceivedMessagesToDevice(const std::vector<std::string> &ids) const = 0;
+ removeInboundP2PMessages(const std::vector<std::string> &ids) const = 0;
#ifdef EMSCRIPTEN
virtual std::vector<WebThread> getAllThreadsWeb() const = 0;
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
@@ -152,12 +152,10 @@
void removeMessagesToDeviceOlderThan(
const ClientMessageToDevice &lastConfirmedMessage) const override;
void removeAllMessagesForDevice(const std::string &deviceID) const override;
+ void addInboundP2PMessage(InboundP2PMessage message) const override;
+ std::vector<InboundP2PMessage> getAllInboundP2PMessage() const override;
void
- addReceivedMessageToDevice(ReceivedMessageToDevice message) const override;
- std::vector<ReceivedMessageToDevice>
- getAllReceivedMessageToDevice() const override;
- void removeReceivedMessagesToDevice(
- const std::vector<std::string> &ids) const override;
+ removeInboundP2PMessages(const std::vector<std::string> &ids) const override;
#ifdef EMSCRIPTEN
std::vector<WebThread> getAllThreadsWeb() const override;
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -2155,27 +2155,27 @@
SQLiteQueryExecutor::getConnection(), removeMessagesSQL, keys);
}
-void SQLiteQueryExecutor::addReceivedMessageToDevice(
- ReceivedMessageToDevice message) const {
+void SQLiteQueryExecutor::addInboundP2PMessage(
+ InboundP2PMessage message) const {
static std::string addMessage =
"REPLACE INTO received_messages_to_device ("
" message_id, sender_device_id, plaintext, status)"
"VALUES (?, ?, ?, ?);";
- replaceEntity<ReceivedMessageToDevice>(
+ replaceEntity<InboundP2PMessage>(
SQLiteQueryExecutor::getConnection(), addMessage, message);
}
-std::vector<ReceivedMessageToDevice>
-SQLiteQueryExecutor::getAllReceivedMessageToDevice() const {
+std::vector<InboundP2PMessage>
+SQLiteQueryExecutor::getAllInboundP2PMessage() const {
static std::string query =
"SELECT message_id, sender_device_id, plaintext, status "
"FROM received_messages_to_device;";
- return getAllEntities<ReceivedMessageToDevice>(
+ return getAllEntities<InboundP2PMessage>(
SQLiteQueryExecutor::getConnection(), query);
}
-void SQLiteQueryExecutor::removeReceivedMessagesToDevice(
+void SQLiteQueryExecutor::removeInboundP2PMessages(
const std::vector<std::string> &ids) const {
if (!ids.size()) {
return;
diff --git a/native/cpp/CommonCpp/DatabaseManagers/entities/ReceivedMessageToDevice.h b/native/cpp/CommonCpp/DatabaseManagers/entities/InboundP2PMessage.h
rename from native/cpp/CommonCpp/DatabaseManagers/entities/ReceivedMessageToDevice.h
rename to native/cpp/CommonCpp/DatabaseManagers/entities/InboundP2PMessage.h
--- a/native/cpp/CommonCpp/DatabaseManagers/entities/ReceivedMessageToDevice.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/entities/InboundP2PMessage.h
@@ -8,14 +8,14 @@
namespace comm {
-struct ReceivedMessageToDevice {
+struct InboundP2PMessage {
std::string message_id;
std::string sender_device_id;
std::string plaintext;
std::string status;
- static ReceivedMessageToDevice fromSQLResult(sqlite3_stmt *sqlRow, int idx) {
- return ReceivedMessageToDevice{
+ static InboundP2PMessage fromSQLResult(sqlite3_stmt *sqlRow, int idx) {
+ return InboundP2PMessage{
getStringFromSQLRow(sqlRow, idx),
getStringFromSQLRow(sqlRow, idx + 1),
getStringFromSQLRow(sqlRow, idx + 2),
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
@@ -196,9 +196,9 @@
jsi::Object siweBackupSecrets) override;
virtual jsi::Value retrieveLatestSIWEBackupData(jsi::Runtime &rt) override;
virtual jsi::Value getSIWEBackupSecrets(jsi::Runtime &rt) override;
- virtual jsi::Value getAllReceivedMessageToDevice(jsi::Runtime &rt) override;
+ virtual jsi::Value getAllInboundP2PMessage(jsi::Runtime &rt) override;
virtual jsi::Value
- removeReceivedMessagesToDevice(jsi::Runtime &rt, jsi::Array ids) override;
+ removeInboundP2PMessages(jsi::Runtime &rt, jsi::Array ids) override;
public:
CommCoreModule(std::shared_ptr<facebook::react::CallInvoker> jsInvoker);
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
@@ -1460,15 +1460,15 @@
GlobalDBSingleton::instance.scheduleOrRunCancellable(
[=, &persistencePromise]() {
try {
- ReceivedMessageToDevice message{
+ InboundP2PMessage message{
messageIDCpp,
deviceIDCpp,
decryptedMessage,
"decrypted"};
DatabaseManager::getQueryExecutor().beginTransaction();
- DatabaseManager::getQueryExecutor()
- .addReceivedMessageToDevice(message);
+ DatabaseManager::getQueryExecutor().addInboundP2PMessage(
+ message);
DatabaseManager::getQueryExecutor().storeOlmPersistData(
DatabaseManager::getQueryExecutor()
.getContentAccountID(),
@@ -2140,23 +2140,22 @@
});
}
-jsi::Value CommCoreModule::getAllReceivedMessageToDevice(jsi::Runtime &rt) {
+jsi::Value CommCoreModule::getAllInboundP2PMessage(jsi::Runtime &rt) {
return createPromiseAsJSIValue(
rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
taskType job = [=, &innerRt]() {
std::string error;
- std::vector<ReceivedMessageToDevice> messages;
+ std::vector<InboundP2PMessage> messages;
try {
- messages = DatabaseManager::getQueryExecutor()
- .getAllReceivedMessageToDevice();
+ messages =
+ DatabaseManager::getQueryExecutor().getAllInboundP2PMessage();
} catch (std::system_error &e) {
error = e.what();
}
- auto messagesPtr =
- std::make_shared<std::vector<ReceivedMessageToDevice>>(
- std::move(messages));
+ auto messagesPtr = std::make_shared<std::vector<InboundP2PMessage>>(
+ std::move(messages));
this->jsInvoker_->invokeAsync(
[&innerRt, messagesPtr, error, promise]() {
@@ -2168,7 +2167,7 @@
jsi::Array jsiMessages =
jsi::Array(innerRt, messagesPtr->size());
size_t writeIdx = 0;
- for (const ReceivedMessageToDevice &msg : *messagesPtr) {
+ for (const InboundP2PMessage &msg : *messagesPtr) {
jsi::Object jsiMsg = jsi::Object(innerRt);
jsiMsg.setProperty(innerRt, "messageID", msg.message_id);
jsiMsg.setProperty(
@@ -2186,9 +2185,8 @@
});
}
-jsi::Value CommCoreModule::removeReceivedMessagesToDevice(
- jsi::Runtime &rt,
- jsi::Array ids) {
+jsi::Value
+CommCoreModule::removeInboundP2PMessages(jsi::Runtime &rt, jsi::Array ids) {
std::vector<std::string> msgIDsCPP{};
for (auto idx = 0; idx < ids.size(rt); idx++) {
std::string msgID = ids.getValueAtIndex(rt, idx).asString(rt).utf8(rt);
@@ -2202,7 +2200,7 @@
taskType job = [this, promise, msgIDsCPP]() {
std::string error;
try {
- DatabaseManager::getQueryExecutor().removeReceivedMessagesToDevice(
+ DatabaseManager::getQueryExecutor().removeInboundP2PMessages(
msgIDsCPP);
} catch (std::system_error &e) {
error = e.what();
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
@@ -181,11 +181,11 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getSIWEBackupSecrets(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getSIWEBackupSecrets(rt);
}
-static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllReceivedMessageToDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
- return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getAllReceivedMessageToDevice(rt);
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllInboundP2PMessage(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getAllInboundP2PMessage(rt);
}
-static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeReceivedMessagesToDevice(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
- return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->removeReceivedMessagesToDevice(rt, args[0].asObject(rt).asArray(rt));
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeInboundP2PMessages(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->removeInboundP2PMessages(rt, args[0].asObject(rt).asArray(rt));
}
CommCoreModuleSchemaCxxSpecJSI::CommCoreModuleSchemaCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
@@ -244,8 +244,8 @@
methodMap_["retrieveLatestSIWEBackupData"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_retrieveLatestSIWEBackupData};
methodMap_["setSIWEBackupSecrets"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setSIWEBackupSecrets};
methodMap_["getSIWEBackupSecrets"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getSIWEBackupSecrets};
- methodMap_["getAllReceivedMessageToDevice"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllReceivedMessageToDevice};
- methodMap_["removeReceivedMessagesToDevice"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeReceivedMessagesToDevice};
+ methodMap_["getAllInboundP2PMessage"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllInboundP2PMessage};
+ methodMap_["removeInboundP2PMessages"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeInboundP2PMessages};
}
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
@@ -74,8 +74,8 @@
virtual jsi::Value retrieveLatestSIWEBackupData(jsi::Runtime &rt) = 0;
virtual jsi::Value setSIWEBackupSecrets(jsi::Runtime &rt, jsi::Object siweBackupSecrets) = 0;
virtual jsi::Value getSIWEBackupSecrets(jsi::Runtime &rt) = 0;
- virtual jsi::Value getAllReceivedMessageToDevice(jsi::Runtime &rt) = 0;
- virtual jsi::Value removeReceivedMessagesToDevice(jsi::Runtime &rt, jsi::Array ids) = 0;
+ virtual jsi::Value getAllInboundP2PMessage(jsi::Runtime &rt) = 0;
+ virtual jsi::Value removeInboundP2PMessages(jsi::Runtime &rt, jsi::Array ids) = 0;
};
@@ -529,21 +529,21 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::getSIWEBackupSecrets, jsInvoker_, instance_);
}
- jsi::Value getAllReceivedMessageToDevice(jsi::Runtime &rt) override {
+ jsi::Value getAllInboundP2PMessage(jsi::Runtime &rt) override {
static_assert(
- bridging::getParameterCount(&T::getAllReceivedMessageToDevice) == 1,
- "Expected getAllReceivedMessageToDevice(...) to have 1 parameters");
+ bridging::getParameterCount(&T::getAllInboundP2PMessage) == 1,
+ "Expected getAllInboundP2PMessage(...) to have 1 parameters");
return bridging::callFromJs<jsi::Value>(
- rt, &T::getAllReceivedMessageToDevice, jsInvoker_, instance_);
+ rt, &T::getAllInboundP2PMessage, jsInvoker_, instance_);
}
- jsi::Value removeReceivedMessagesToDevice(jsi::Runtime &rt, jsi::Array ids) override {
+ jsi::Value removeInboundP2PMessages(jsi::Runtime &rt, jsi::Array ids) override {
static_assert(
- bridging::getParameterCount(&T::removeReceivedMessagesToDevice) == 2,
- "Expected removeReceivedMessagesToDevice(...) to have 2 parameters");
+ bridging::getParameterCount(&T::removeInboundP2PMessages) == 2,
+ "Expected removeInboundP2PMessages(...) to have 2 parameters");
return bridging::callFromJs<jsi::Value>(
- rt, &T::removeReceivedMessagesToDevice, jsInvoker_, instance_, std::move(ids));
+ rt, &T::removeInboundP2PMessages, jsInvoker_, instance_, std::move(ids));
}
private:
diff --git a/native/database/sqlite-api.js b/native/database/sqlite-api.js
--- a/native/database/sqlite-api.js
+++ b/native/database/sqlite-api.js
@@ -7,10 +7,10 @@
const sqliteAPI: SQLiteAPI = {
// read operations
- getAllReceivedMessageToDevice: commCoreModule.getAllReceivedMessageToDevice,
+ getAllInboundP2PMessage: commCoreModule.getAllInboundP2PMessage,
// write operations
- removeReceivedMessagesToDevice: commCoreModule.removeReceivedMessagesToDevice,
+ removeInboundP2PMessages: commCoreModule.removeInboundP2PMessages,
processDBStoreOperations,
};
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -17,7 +17,7 @@
} from 'lib/types/crypto-types.js';
import type { ClientDBMessageInfo } from 'lib/types/message-types.js';
import type { SIWEBackupSecrets } from 'lib/types/siwe-types.js';
-import type { ReceivedMessageToDevice } from 'lib/types/sqlite-types.js';
+import type { InboundP2PMessage } from 'lib/types/sqlite-types.js';
import type {
ClientDBStore,
ClientDBStoreOperations,
@@ -138,10 +138,8 @@
+retrieveLatestSIWEBackupData: () => Promise<string>;
+setSIWEBackupSecrets: (siweBackupSecrets: Object) => Promise<void>;
+getSIWEBackupSecrets: () => Promise<?Object>;
- +getAllReceivedMessageToDevice: () => Promise<ReceivedMessageToDevice[]>;
- +removeReceivedMessagesToDevice: (
- ids: $ReadOnlyArray<string>,
- ) => Promise<void>;
+ +getAllInboundP2PMessage: () => Promise<InboundP2PMessage[]>;
+ +removeInboundP2PMessages: (ids: $ReadOnlyArray<string>) => Promise<void>;
}
export interface CoreModuleSpec extends Spec {
diff --git a/web/cpp/SQLiteQueryExecutorBindings.cpp b/web/cpp/SQLiteQueryExecutorBindings.cpp
--- a/web/cpp/SQLiteQueryExecutorBindings.cpp
+++ b/web/cpp/SQLiteQueryExecutorBindings.cpp
@@ -1,7 +1,7 @@
#include "SQLiteQueryExecutor.cpp"
+#include "entities/InboundP2PMessage.h"
#include "entities/MessageToDevice.h"
#include "entities/Nullable.h"
-#include "entities/ReceivedMessageToDevice.h"
#include <emscripten/bind.h>
#include <vector>
@@ -122,11 +122,11 @@
.field("plaintext", &ClientMessageToDevice::plaintext)
.field("ciphertext", &ClientMessageToDevice::ciphertext);
- value_object<ReceivedMessageToDevice>("ReceivedMessageToDevice")
- .field("messageID", &ReceivedMessageToDevice::message_id)
- .field("senderDeviceID", &ReceivedMessageToDevice::sender_device_id)
- .field("plaintext", &ReceivedMessageToDevice::plaintext)
- .field("status", &ReceivedMessageToDevice::status);
+ value_object<InboundP2PMessage>("InboundP2PMessage")
+ .field("messageID", &InboundP2PMessage::message_id)
+ .field("senderDeviceID", &InboundP2PMessage::sender_device_id)
+ .field("plaintext", &InboundP2PMessage::plaintext)
+ .field("status", &InboundP2PMessage::status);
class_<SQLiteQueryExecutor>("SQLiteQueryExecutor")
.constructor<std::string>()
@@ -273,14 +273,13 @@
"getAllMessagesToDevice",
&SQLiteQueryExecutor::getAllMessagesToDevice)
.function(
- "addReceivedMessageToDevice",
- &SQLiteQueryExecutor::addReceivedMessageToDevice)
+ "addInboundP2PMessage", &SQLiteQueryExecutor::addInboundP2PMessage)
.function(
- "getAllReceivedMessageToDevice",
- &SQLiteQueryExecutor::getAllReceivedMessageToDevice)
+ "getAllInboundP2PMessage",
+ &SQLiteQueryExecutor::getAllInboundP2PMessage)
.function(
- "removeReceivedMessagesToDevice",
- &SQLiteQueryExecutor::removeReceivedMessagesToDevice);
+ "removeInboundP2PMessages",
+ &SQLiteQueryExecutor::removeInboundP2PMessages);
}
} // namespace comm
diff --git a/web/database/sqlite-api.js b/web/database/sqlite-api.js
--- a/web/database/sqlite-api.js
+++ b/web/database/sqlite-api.js
@@ -1,9 +1,6 @@
// @flow
-import type {
- SQLiteAPI,
- ReceivedMessageToDevice,
-} from 'lib/types/sqlite-types.js';
+import type { SQLiteAPI, InboundP2PMessage } from 'lib/types/sqlite-types.js';
import { getCommSharedWorker } from '../shared-worker/shared-worker-provider.js';
import { processDBStoreOperations } from '../shared-worker/utils/store.js';
@@ -11,24 +8,22 @@
const sqliteAPI: SQLiteAPI = {
// read operations
- async getAllReceivedMessageToDevice(): Promise<ReceivedMessageToDevice[]> {
+ async getAllInboundP2PMessage(): Promise<InboundP2PMessage[]> {
const sharedWorker = await getCommSharedWorker();
const data = await sharedWorker.schedule({
- type: workerRequestMessageTypes.GET_RECEIVED_MESSAGES_TO_DEVICE,
+ type: workerRequestMessageTypes.GET_INBOUND_P2P_MESSAGES,
});
- const messages: ?$ReadOnlyArray<ReceivedMessageToDevice> = data?.messages;
+ const messages: ?$ReadOnlyArray<InboundP2PMessage> = data?.messages;
return messages ? [...messages] : [];
},
// write operations
- async removeReceivedMessagesToDevice(
- ids: $ReadOnlyArray<string>,
- ): Promise<void> {
+ async removeInboundP2PMessages(ids: $ReadOnlyArray<string>): Promise<void> {
const sharedWorker = await getCommSharedWorker();
await sharedWorker.schedule({
- type: workerRequestMessageTypes.REMOVE_RECEIVED_MESSAGES_TO_DEVICE,
+ type: workerRequestMessageTypes.REMOVE_INBOUND_P2P_MESSAGES,
ids,
});
},
diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_generated/comm_query_executor.wasm
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
diff --git a/web/shared-worker/queries/received-messages-to-device-queries.test.js b/web/shared-worker/queries/inbound-p2p-message-queries.test.js
rename from web/shared-worker/queries/received-messages-to-device-queries.test.js
rename to web/shared-worker/queries/inbound-p2p-message-queries.test.js
--- a/web/shared-worker/queries/received-messages-to-device-queries.test.js
+++ b/web/shared-worker/queries/inbound-p2p-message-queries.test.js
@@ -1,6 +1,6 @@
// @flow
-import type { ReceivedMessageToDevice } from 'lib/types/sqlite-types.js';
+import type { InboundP2PMessage } from 'lib/types/sqlite-types.js';
import { getDatabaseModule } from '../db-module.js';
import type { EmscriptenModule } from '../types/module.js';
@@ -12,21 +12,21 @@
const device1 = 'device-1';
const device2 = 'device-2';
-const TEST_MSG_1: ReceivedMessageToDevice = {
+const TEST_MSG_1: InboundP2PMessage = {
messageID: 'id-1',
senderDeviceID: device1,
plaintext: 'decrypted-1',
status: 'none',
};
-const TEST_MSG_2: ReceivedMessageToDevice = {
+const TEST_MSG_2: InboundP2PMessage = {
messageID: 'id-2',
senderDeviceID: device2,
plaintext: 'decrypted-2',
status: 'none',
};
-const TEST_MSG_3: ReceivedMessageToDevice = {
+const TEST_MSG_3: InboundP2PMessage = {
messageID: 'id-3',
senderDeviceID: device1,
plaintext: 'decrypted-3',
@@ -35,7 +35,7 @@
const messagesOrdered = [TEST_MSG_1, TEST_MSG_2, TEST_MSG_3];
-describe('Received messages to device queries', () => {
+describe('Inbound P2P message queries', () => {
let queryExecutor: ?SQLiteQueryExecutor = null;
let dbModule: ?EmscriptenModule = null;
@@ -51,9 +51,9 @@
if (!queryExecutor) {
throw new Error('SQLiteQueryExecutor is missing');
}
- queryExecutor?.addReceivedMessageToDevice(TEST_MSG_1);
- queryExecutor?.addReceivedMessageToDevice(TEST_MSG_2);
- queryExecutor?.addReceivedMessageToDevice(TEST_MSG_3);
+ queryExecutor?.addInboundP2PMessage(TEST_MSG_1);
+ queryExecutor?.addInboundP2PMessage(TEST_MSG_2);
+ queryExecutor?.addInboundP2PMessage(TEST_MSG_3);
});
afterEach(() => {
@@ -64,13 +64,13 @@
});
it('should return all messages', () => {
- const messages = queryExecutor?.getAllReceivedMessageToDevice() ?? [];
+ const messages = queryExecutor?.getAllInboundP2PMessage() ?? [];
expect(messages.length).toBe(3);
expect(messages).toStrictEqual(messagesOrdered);
});
it('should remove messages', () => {
- queryExecutor?.removeReceivedMessagesToDevice([TEST_MSG_2.messageID]);
- const messages = queryExecutor?.getAllReceivedMessageToDevice() ?? [];
+ queryExecutor?.removeInboundP2PMessages([TEST_MSG_2.messageID]);
+ const messages = queryExecutor?.getAllInboundP2PMessage() ?? [];
expect(messages.length).toBe(2);
expect(messages).toStrictEqual([TEST_MSG_1, TEST_MSG_3]);
});
diff --git a/web/shared-worker/types/sqlite-query-executor.js b/web/shared-worker/types/sqlite-query-executor.js
--- a/web/shared-worker/types/sqlite-query-executor.js
+++ b/web/shared-worker/types/sqlite-query-executor.js
@@ -9,7 +9,7 @@
import type { ClientDBThreadActivityEntry } from 'lib/ops/thread-activity-store-ops.js';
import type { ClientDBUserInfo } from 'lib/ops/user-store-ops.js';
import type { ClientDBDraftInfo } from 'lib/types/draft-types.js';
-import type { ReceivedMessageToDevice } from 'lib/types/sqlite-types.js';
+import type { InboundP2PMessage } from 'lib/types/sqlite-types.js';
import {
type WebClientDBThreadInfo,
@@ -172,9 +172,9 @@
deviceID: string,
): $ReadOnlyArray<ClientMessageToDevice>;
- addReceivedMessageToDevice(message: ReceivedMessageToDevice): void;
- getAllReceivedMessageToDevice(): $ReadOnlyArray<ReceivedMessageToDevice>;
- removeReceivedMessagesToDevice(ids: $ReadOnlyArray<string>): void;
+ addInboundP2PMessage(message: InboundP2PMessage): void;
+ getAllInboundP2PMessage(): $ReadOnlyArray<InboundP2PMessage>;
+ removeInboundP2PMessages(ids: $ReadOnlyArray<string>): void;
// method is provided to manually signal that a C++ object
// is no longer needed and can be deleted
diff --git a/web/shared-worker/worker/shared-worker.js b/web/shared-worker/worker/shared-worker.js
--- a/web/shared-worker/worker/shared-worker.js
+++ b/web/shared-worker/worker/shared-worker.js
@@ -239,11 +239,11 @@
item: sqliteQueryExecutor.getPersistStorageItem(message.key),
};
} else if (
- message.type === workerRequestMessageTypes.GET_RECEIVED_MESSAGES_TO_DEVICE
+ message.type === workerRequestMessageTypes.GET_INBOUND_P2P_MESSAGES
) {
return {
- type: workerResponseMessageTypes.GET_RECEIVED_MESSAGES_TO_DEVICE,
- messages: sqliteQueryExecutor.getAllReceivedMessageToDevice(),
+ type: workerResponseMessageTypes.GET_INBOUND_P2P_MESSAGES,
+ messages: sqliteQueryExecutor.getAllInboundP2PMessage(),
};
}
@@ -311,10 +311,9 @@
message.backupLogDataKey,
);
} else if (
- message.type ===
- workerRequestMessageTypes.REMOVE_RECEIVED_MESSAGES_TO_DEVICE
+ message.type === workerRequestMessageTypes.REMOVE_INBOUND_P2P_MESSAGES
) {
- sqliteQueryExecutor.removeReceivedMessagesToDevice(message.ids);
+ sqliteQueryExecutor.removeInboundP2PMessages(message.ids);
}
persistNeeded = true;
diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js
--- a/web/shared-worker/worker/worker-crypto.js
+++ b/web/shared-worker/worker/worker-crypto.js
@@ -24,7 +24,7 @@
IdentityExistingDeviceKeyUpload,
} from 'lib/types/identity-service-types.js';
import type { OlmSessionInitializationInfo } from 'lib/types/request-types.js';
-import type { ReceivedMessageToDevice } from 'lib/types/sqlite-types.js';
+import type { InboundP2PMessage } from 'lib/types/sqlite-types.js';
import { getMessageForException } from 'lib/utils/errors.js';
import { entries } from 'lib/utils/objects.js';
import {
@@ -492,7 +492,7 @@
);
}
- const receivedMessage: ReceivedMessageToDevice = {
+ const receivedMessage: InboundP2PMessage = {
messageID,
senderDeviceID: deviceID,
plaintext: result,
@@ -501,7 +501,7 @@
sqliteQueryExecutor.beginTransaction();
try {
- sqliteQueryExecutor.addReceivedMessageToDevice(receivedMessage);
+ sqliteQueryExecutor.addInboundP2PMessage(receivedMessage);
persistCryptoStore(true);
sqliteQueryExecutor.commitTransaction();
} catch (e) {
diff --git a/web/types/worker-types.js b/web/types/worker-types.js
--- a/web/types/worker-types.js
+++ b/web/types/worker-types.js
@@ -11,7 +11,7 @@
IdentityServiceClient,
IdentityServiceAuthLayer,
} from 'lib/types/identity-service-types.js';
-import type { ReceivedMessageToDevice } from 'lib/types/sqlite-types.js';
+import type { InboundP2PMessage } from 'lib/types/sqlite-types.js';
import type {
ClientDBStore,
ClientDBStoreOperations,
@@ -35,8 +35,8 @@
CREATE_IDENTITY_SERVICE_CLIENT: 13,
CALL_IDENTITY_CLIENT_METHOD: 14,
CALL_OLM_API_METHOD: 15,
- GET_RECEIVED_MESSAGES_TO_DEVICE: 16,
- REMOVE_RECEIVED_MESSAGES_TO_DEVICE: 17,
+ GET_INBOUND_P2P_MESSAGES: 16,
+ REMOVE_INBOUND_P2P_MESSAGES: 17,
});
export const workerWriteRequests: $ReadOnlyArray<number> = [
@@ -46,7 +46,7 @@
workerRequestMessageTypes.REMOVE_PERSIST_STORAGE_ITEM,
workerRequestMessageTypes.BACKUP_RESTORE,
workerRequestMessageTypes.INITIALIZE_CRYPTO_ACCOUNT,
- workerRequestMessageTypes.REMOVE_RECEIVED_MESSAGES_TO_DEVICE,
+ workerRequestMessageTypes.REMOVE_INBOUND_P2P_MESSAGES,
];
export const workerOlmAPIRequests: $ReadOnlyArray<number> = [
@@ -155,11 +155,11 @@
+args: $ReadOnlyArray<mixed>,
};
-export type GetReceivedMessagesToDeviceRequestMessage = {
+export type GetInboundP2PMessagesRequestMessage = {
+type: 16,
};
-export type RemoveReceivedMessagesToDeviceRequestMessage = {
+export type RemoveInboundP2PMessagesRequestMessage = {
+type: 17,
+ids: $ReadOnlyArray<string>,
};
@@ -181,8 +181,8 @@
| CreateIdentityServiceClientRequestMessage
| CallIdentityClientMethodRequestMessage
| CallOLMApiMethodRequestMessage
- | GetReceivedMessagesToDeviceRequestMessage
- | RemoveReceivedMessagesToDeviceRequestMessage;
+ | GetInboundP2PMessagesRequestMessage
+ | RemoveInboundP2PMessagesRequestMessage;
export type WorkerRequestProxyMessage = {
+id: number,
@@ -197,7 +197,7 @@
GET_PERSIST_STORAGE_ITEM: 3,
CALL_IDENTITY_CLIENT_METHOD: 4,
CALL_OLM_API_METHOD: 5,
- GET_RECEIVED_MESSAGES_TO_DEVICE: 6,
+ GET_INBOUND_P2P_MESSAGES: 6,
});
export type PongWorkerResponseMessage = {
@@ -230,9 +230,9 @@
+result: mixed,
};
-export type GetReceivedMessagesToDeviceResponseMessage = {
+export type GetInboundP2PMessagesResponseMessage = {
+type: 6,
- +messages: $ReadOnlyArray<ReceivedMessageToDevice>,
+ +messages: $ReadOnlyArray<InboundP2PMessage>,
};
export type WorkerResponseMessage =
@@ -242,7 +242,7 @@
| GetPersistStorageItemResponseMessage
| CallIdentityClientMethodResponseMessage
| CallOLMApiMethodResponseMessage
- | GetReceivedMessagesToDeviceResponseMessage;
+ | GetInboundP2PMessagesResponseMessage;
export type WorkerResponseProxyMessage = {
+id?: number,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 5:14 PM (4 m, 48 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700559
Default Alt Text
D12046.id.diff (31 KB)
Attached To
Mode
D12046: [lib] rename `ReceivedMessageToDevice` to `InboundP2PMessage`
Attached
Detach File
Event Timeline
Log In to Comment