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 @@ -43,6 +43,9 @@ +getAllInboundP2PMessage: () => Promise, +getAllOutboundP2PMessage: () => Promise, +getRelatedMessages: (messageID: string) => Promise, + +getOutboundP2PMessagesByID: ( + ids: $ReadOnlyArray, + ) => Promise<$ReadOnlyArray>, // write operations +removeInboundP2PMessages: (ids: $ReadOnlyArray) => 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 @@ -36,6 +36,7 @@ markOutboundP2PMessageAsSent: jest.fn(), removeOutboundP2PMessagesOlderThan: jest.fn(), getRelatedMessages: jest.fn(), + getOutboundP2PMessagesByID: jest.fn(), }, }); 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 @@ -10,6 +10,7 @@ getAllInboundP2PMessage: commCoreModule.getAllInboundP2PMessage, getAllOutboundP2PMessage: commCoreModule.getAllOutboundP2PMessage, getRelatedMessages: commCoreModule.getRelatedMessages, + getOutboundP2PMessagesByID: commCoreModule.getOutboundP2PMessagesByID, // write operations removeInboundP2PMessages: commCoreModule.removeInboundP2PMessages, 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 @@ -46,6 +46,20 @@ return messages ? [...messages] : []; }, + async getOutboundP2PMessagesByID( + ids: $ReadOnlyArray, + ): Promise<$ReadOnlyArray> { + const sharedWorker = await getCommSharedWorker(); + + const data = await sharedWorker.schedule({ + type: workerRequestMessageTypes.GET_OUTBOUND_P2P_MESSAGES_BY_ID, + messageIDs: ids, + }); + const messages: ?$ReadOnlyArray = + data?.outboundP2PMessages; + return messages ? [...messages] : []; + }, + // write operations async removeInboundP2PMessages(ids: $ReadOnlyArray): Promise { const sharedWorker = await getCommSharedWorker(); 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 @@ -261,6 +261,15 @@ type: workerResponseMessageTypes.GET_RELATED_MESSAGES, messages: webMessageEntities.map(webMessageToClientDBMessageInfo), }; + } else if ( + message.type === workerRequestMessageTypes.GET_OUTBOUND_P2P_MESSAGES_BY_ID + ) { + return { + type: workerResponseMessageTypes.GET_OUTBOUND_P2P_MESSAGES, + outboundP2PMessages: sqliteQueryExecutor.getOutboundP2PMessagesByID( + message.messageIDs, + ), + }; } // write operations 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 @@ -45,6 +45,7 @@ MARK_OUTBOUND_P2P_MESSAGE_AS_SENT: 19, REMOVE_OUTBOUND_P2P_MESSAGES: 20, GET_RELATED_MESSAGES: 21, + GET_OUTBOUND_P2P_MESSAGES_BY_ID: 22, }); export const workerWriteRequests: $ReadOnlyArray = [ @@ -195,6 +196,11 @@ +messageID: string, }; +export type GetOutboundP2PMessageRequestMessage = { + +type: 22, + +messageIDs: $ReadOnlyArray, +}; + export type WorkerRequestMessage = | PingWorkerRequestMessage | InitWorkerRequestMessage @@ -217,7 +223,8 @@ | GetOutboundP2PMessagesRequestMessage | MarkOutboundP2PMessageAsSentRequestMessage | RemoveOutboundP2PMessagesRequestMessage - | GetRelatedMessagesRequestMessage; + | GetRelatedMessagesRequestMessage + | GetOutboundP2PMessageRequestMessage; export type WorkerRequestProxyMessage = { +id: number,