Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3348361
D12080.id40299.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12080.id40299.diff
View Options
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
@@ -22,9 +22,18 @@
export type SQLiteAPI = {
// read operations
+getAllInboundP2PMessage: () => Promise<InboundP2PMessage[]>,
+ +getAllOutboundP2PMessage: () => Promise<OutboundP2PMessage[]>,
// write operations
+removeInboundP2PMessages: (ids: $ReadOnlyArray<string>) => Promise<void>,
+ +markOutboundP2PMessageAsSent: (
+ messageID: string,
+ deviceID: string,
+ ) => Promise<void>,
+ +removeOutboundP2PMessagesOlderThan: (
+ messageID: string,
+ deviceID: 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
@@ -30,6 +30,9 @@
getAllInboundP2PMessage: jest.fn(),
removeInboundP2PMessages: jest.fn(),
processDBStoreOperations: jest.fn(),
+ getAllOutboundP2PMessage: jest.fn(),
+ markOutboundP2PMessageAsSent: jest.fn(),
+ removeOutboundP2PMessagesOlderThan: 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
@@ -8,9 +8,13 @@
const sqliteAPI: SQLiteAPI = {
// read operations
getAllInboundP2PMessage: commCoreModule.getAllInboundP2PMessage,
+ getAllOutboundP2PMessage: commCoreModule.getAllOutboundP2PMessage,
// write operations
removeInboundP2PMessages: commCoreModule.removeInboundP2PMessages,
+ markOutboundP2PMessageAsSent: commCoreModule.markOutboundP2PMessageAsSent,
+ removeOutboundP2PMessagesOlderThan:
+ commCoreModule.removeOutboundP2PMessagesOlderThan,
processDBStoreOperations,
};
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,6 +1,10 @@
// @flow
-import type { SQLiteAPI, InboundP2PMessage } from 'lib/types/sqlite-types.js';
+import type {
+ SQLiteAPI,
+ InboundP2PMessage,
+ OutboundP2PMessage,
+} from 'lib/types/sqlite-types.js';
import { getCommSharedWorker } from '../shared-worker/shared-worker-provider.js';
import { processDBStoreOperations } from '../shared-worker/utils/store.js';
@@ -19,6 +23,17 @@
return messages ? [...messages] : [];
},
+ async getAllOutboundP2PMessage(): Promise<OutboundP2PMessage[]> {
+ const sharedWorker = await getCommSharedWorker();
+
+ const data = await sharedWorker.schedule({
+ type: workerRequestMessageTypes.GET_OUTBOUND_P2P_MESSAGES,
+ });
+ const messages: ?$ReadOnlyArray<OutboundP2PMessage> =
+ data?.outboundP2PMessages;
+ return messages ? [...messages] : [];
+ },
+
// write operations
async removeInboundP2PMessages(ids: $ReadOnlyArray<string>): Promise<void> {
const sharedWorker = await getCommSharedWorker();
@@ -29,6 +44,32 @@
});
},
+ async markOutboundP2PMessageAsSent(
+ messageID: string,
+ deviceID: string,
+ ): Promise<void> {
+ const sharedWorker = await getCommSharedWorker();
+
+ await sharedWorker.schedule({
+ type: workerRequestMessageTypes.MARK_OUTBOUND_P2P_MESSAGE_AS_SENT,
+ messageID,
+ deviceID,
+ });
+ },
+
+ async removeOutboundP2PMessagesOlderThan(
+ messageID: string,
+ deviceID: string,
+ ): Promise<void> {
+ const sharedWorker = await getCommSharedWorker();
+
+ await sharedWorker.schedule({
+ type: workerRequestMessageTypes.REMOVE_OUTBOUND_P2P_MESSAGES,
+ messageID,
+ deviceID,
+ });
+ },
+
processDBStoreOperations,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 2:36 PM (18 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2571183
Default Alt Text
D12080.id40299.diff (3 KB)
Attached To
Mode
D12080: [lib] implement Outbound P2P Messages API in `SQLiteAPI`
Attached
Detach File
Event Timeline
Log In to Comment