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 @@ -48,6 +48,12 @@ +getOutboundP2PMessagesByID: ( ids: $ReadOnlyArray, ) => Promise>, + +searchMessages: ( + query: string, + threadID: string, + timestampCursor: ?string, + messageIDCursor: ?string, + ) => Promise>, // 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 @@ -37,6 +37,7 @@ removeOutboundP2PMessagesOlderThan: jest.fn(), getRelatedMessages: jest.fn(), getOutboundP2PMessagesByID: jest.fn(), + searchMessages: 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 @@ -11,6 +11,7 @@ getAllOutboundP2PMessage: commCoreModule.getAllOutboundP2PMessage, getRelatedMessages: commCoreModule.getRelatedMessages, getOutboundP2PMessagesByID: commCoreModule.getOutboundP2PMessagesByID, + searchMessages: commCoreModule.searchMessages, // 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 @@ -60,6 +60,25 @@ return messages ? [...messages] : []; }, + async searchMessages( + query: string, + threadID: string, + timestampCursor: ?string, + messageIDCursor: ?string, + ): Promise { + const sharedWorker = await getCommSharedWorker(); + + const data = await sharedWorker.schedule({ + type: workerRequestMessageTypes.SEARCH_MESSAGES, + query, + threadID, + timestampCursor, + messageIDCursor, + }); + const messages: ?$ReadOnlyArray = data?.messages; + return messages ? [...messages] : []; + }, + // write operations async removeInboundP2PMessages(ids: $ReadOnlyArray): Promise { const sharedWorker = await getCommSharedWorker();