diff --git a/lib/tunnelbroker/peer-to-peer-context.js b/lib/tunnelbroker/peer-to-peer-context.js --- a/lib/tunnelbroker/peer-to-peer-context.js +++ b/lib/tunnelbroker/peer-to-peer-context.js @@ -57,7 +57,7 @@ if (messageIDs) { messages = await sqliteAPI.getOutboundP2PMessagesByID(messageIDs); } else { - const allMessages = await sqliteAPI.getAllOutboundP2PMessage(); + const allMessages = await sqliteAPI.getAllOutboundP2PMessages(); messages = allMessages.filter(message => message.supportsAutoRetry); } 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 @@ -40,8 +40,8 @@ export type SQLiteAPI = { // read operations - +getAllInboundP2PMessage: () => Promise>, - +getAllOutboundP2PMessage: () => Promise>, + +getAllInboundP2PMessages: () => Promise>, + +getAllOutboundP2PMessages: () => Promise>, +getRelatedMessages: ( messageID: string, ) => Promise>, 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 @@ -29,10 +29,10 @@ markPrekeysAsPublished: jest.fn(), }, sqliteAPI: { - getAllInboundP2PMessage: jest.fn(), + getAllInboundP2PMessages: jest.fn(), removeInboundP2PMessages: jest.fn(), processDBStoreOperations: jest.fn(), - getAllOutboundP2PMessage: jest.fn(), + getAllOutboundP2PMessages: jest.fn(), markOutboundP2PMessageAsSent: jest.fn(), removeOutboundP2PMessagesOlderThan: jest.fn(), getRelatedMessages: jest.fn(), 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 @@ -219,12 +219,12 @@ jsi::Object siweBackupSecrets) override; virtual jsi::Value retrieveLatestSIWEBackupData(jsi::Runtime &rt) override; virtual jsi::Value getSIWEBackupSecrets(jsi::Runtime &rt) override; - virtual jsi::Value getAllInboundP2PMessage(jsi::Runtime &rt) override; + virtual jsi::Value getAllInboundP2PMessages(jsi::Runtime &rt) override; virtual jsi::Value removeInboundP2PMessages(jsi::Runtime &rt, jsi::Array ids) override; virtual jsi::Value getOutboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) override; - virtual jsi::Value getAllOutboundP2PMessage(jsi::Runtime &rt) override; + virtual jsi::Value getAllOutboundP2PMessages(jsi::Runtime &rt) override; virtual jsi::Value markOutboundP2PMessageAsSent( jsi::Runtime &rt, jsi::String messageID, 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 @@ -2349,7 +2349,7 @@ }); } -jsi::Value CommCoreModule::getAllInboundP2PMessage(jsi::Runtime &rt) { +jsi::Value CommCoreModule::getAllInboundP2PMessages(jsi::Runtime &rt) { return createPromiseAsJSIValue( rt, [=](jsi::Runtime &innerRt, std::shared_ptr promise) { taskType job = [=, &innerRt]() { @@ -2484,7 +2484,7 @@ }); } -jsi::Value CommCoreModule::getAllOutboundP2PMessage(jsi::Runtime &rt) { +jsi::Value CommCoreModule::getAllOutboundP2PMessages(jsi::Runtime &rt) { return createPromiseAsJSIValue( rt, [=](jsi::Runtime &innerRt, std::shared_ptr promise) { taskType job = [=, &innerRt]() { 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 @@ -187,8 +187,8 @@ static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getSIWEBackupSecrets(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getSIWEBackupSecrets(rt); } -static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllInboundP2PMessage(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getAllInboundP2PMessage(rt); +static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllInboundP2PMessages(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getAllInboundP2PMessages(rt); } static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeInboundP2PMessages(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->removeInboundP2PMessages(rt, args[0].asObject(rt).asArray(rt)); @@ -196,8 +196,8 @@ static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getOutboundP2PMessagesByID(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getOutboundP2PMessagesByID(rt, args[0].asObject(rt).asArray(rt)); } -static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllOutboundP2PMessage(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getAllOutboundP2PMessage(rt); +static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllOutboundP2PMessages(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getAllOutboundP2PMessages(rt); } static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_markOutboundP2PMessageAsSent(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->markOutboundP2PMessageAsSent(rt, args[0].asString(rt), args[1].asString(rt)); @@ -273,10 +273,10 @@ methodMap_["retrieveLatestSIWEBackupData"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_retrieveLatestSIWEBackupData}; methodMap_["setSIWEBackupSecrets"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setSIWEBackupSecrets}; methodMap_["getSIWEBackupSecrets"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getSIWEBackupSecrets}; - methodMap_["getAllInboundP2PMessage"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllInboundP2PMessage}; + methodMap_["getAllInboundP2PMessages"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllInboundP2PMessages}; methodMap_["removeInboundP2PMessages"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeInboundP2PMessages}; methodMap_["getOutboundP2PMessagesByID"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getOutboundP2PMessagesByID}; - methodMap_["getAllOutboundP2PMessage"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllOutboundP2PMessage}; + methodMap_["getAllOutboundP2PMessages"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllOutboundP2PMessages}; methodMap_["markOutboundP2PMessageAsSent"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_markOutboundP2PMessageAsSent}; methodMap_["removeOutboundP2PMessagesOlderThan"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeOutboundP2PMessagesOlderThan}; methodMap_["getSyncedDatabaseVersion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getSyncedDatabaseVersion}; 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 @@ -76,10 +76,10 @@ 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 getAllInboundP2PMessage(jsi::Runtime &rt) = 0; + virtual jsi::Value getAllInboundP2PMessages(jsi::Runtime &rt) = 0; virtual jsi::Value removeInboundP2PMessages(jsi::Runtime &rt, jsi::Array ids) = 0; virtual jsi::Value getOutboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) = 0; - virtual jsi::Value getAllOutboundP2PMessage(jsi::Runtime &rt) = 0; + virtual jsi::Value getAllOutboundP2PMessages(jsi::Runtime &rt) = 0; virtual jsi::Value markOutboundP2PMessageAsSent(jsi::Runtime &rt, jsi::String messageID, jsi::String deviceID) = 0; virtual jsi::Value removeOutboundP2PMessagesOlderThan(jsi::Runtime &rt, jsi::String messageID, jsi::String deviceID) = 0; virtual jsi::Value getSyncedDatabaseVersion(jsi::Runtime &rt) = 0; @@ -554,13 +554,13 @@ return bridging::callFromJs( rt, &T::getSIWEBackupSecrets, jsInvoker_, instance_); } - jsi::Value getAllInboundP2PMessage(jsi::Runtime &rt) override { + jsi::Value getAllInboundP2PMessages(jsi::Runtime &rt) override { static_assert( - bridging::getParameterCount(&T::getAllInboundP2PMessage) == 1, - "Expected getAllInboundP2PMessage(...) to have 1 parameters"); + bridging::getParameterCount(&T::getAllInboundP2PMessages) == 1, + "Expected getAllInboundP2PMessages(...) to have 1 parameters"); return bridging::callFromJs( - rt, &T::getAllInboundP2PMessage, jsInvoker_, instance_); + rt, &T::getAllInboundP2PMessages, jsInvoker_, instance_); } jsi::Value removeInboundP2PMessages(jsi::Runtime &rt, jsi::Array ids) override { static_assert( @@ -578,13 +578,13 @@ return bridging::callFromJs( rt, &T::getOutboundP2PMessagesByID, jsInvoker_, instance_, std::move(ids)); } - jsi::Value getAllOutboundP2PMessage(jsi::Runtime &rt) override { + jsi::Value getAllOutboundP2PMessages(jsi::Runtime &rt) override { static_assert( - bridging::getParameterCount(&T::getAllOutboundP2PMessage) == 1, - "Expected getAllOutboundP2PMessage(...) to have 1 parameters"); + bridging::getParameterCount(&T::getAllOutboundP2PMessages) == 1, + "Expected getAllOutboundP2PMessages(...) to have 1 parameters"); return bridging::callFromJs( - rt, &T::getAllOutboundP2PMessage, jsInvoker_, instance_); + rt, &T::getAllOutboundP2PMessages, jsInvoker_, instance_); } jsi::Value markOutboundP2PMessageAsSent(jsi::Runtime &rt, jsi::String messageID, jsi::String deviceID) override { static_assert( 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,8 +7,8 @@ const sqliteAPI: SQLiteAPI = { // read operations - getAllInboundP2PMessage: commCoreModule.getAllInboundP2PMessage, - getAllOutboundP2PMessage: commCoreModule.getAllOutboundP2PMessage, + getAllInboundP2PMessages: commCoreModule.getAllInboundP2PMessages, + getAllOutboundP2PMessages: commCoreModule.getAllOutboundP2PMessages, getRelatedMessages: commCoreModule.getRelatedMessages, getOutboundP2PMessagesByID: commCoreModule.getOutboundP2PMessagesByID, diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js --- a/native/schema/CommCoreModuleSchema.js +++ b/native/schema/CommCoreModuleSchema.js @@ -152,12 +152,12 @@ +retrieveLatestSIWEBackupData: () => Promise; +setSIWEBackupSecrets: (siweBackupSecrets: Object) => Promise; +getSIWEBackupSecrets: () => Promise; - +getAllInboundP2PMessage: () => Promise; + +getAllInboundP2PMessages: () => Promise; +removeInboundP2PMessages: (ids: $ReadOnlyArray) => Promise; +getOutboundP2PMessagesByID: ( ids: $ReadOnlyArray, ) => Promise>; - +getAllOutboundP2PMessage: () => Promise; + +getAllOutboundP2PMessages: () => Promise; +markOutboundP2PMessageAsSent: ( messageID: string, deviceID: string, 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 @@ -13,7 +13,7 @@ const sqliteAPI: SQLiteAPI = { // read operations - async getAllInboundP2PMessage(): Promise { + async getAllInboundP2PMessages(): Promise { const sharedWorker = await getCommSharedWorker(); const data = await sharedWorker.schedule({ @@ -24,7 +24,7 @@ return messages ? [...messages] : []; }, - async getAllOutboundP2PMessage(): Promise { + async getAllOutboundP2PMessages(): Promise { const sharedWorker = await getCommSharedWorker(); const data = await sharedWorker.schedule({