diff --git a/ts/sql/Client.ts b/ts/sql/Client.ts index 35906a85fa..5c52118863 100644 --- a/ts/sql/Client.ts +++ b/ts/sql/Client.ts @@ -144,8 +144,6 @@ const dataInterface: ClientInterface = { createOrUpdateSession, createOrUpdateSessions, commitSessionsAndUnprocessed, - getSessionById, - getSessionsById, bulkAddSessions, removeSessionById, removeSessionsByConversation, @@ -202,8 +200,6 @@ const dataInterface: ClientInterface = { getUnprocessedCount, getAllUnprocessed, getUnprocessedById, - saveUnprocessed, - saveUnprocesseds, updateUnprocessedAttempts, updateUnprocessedWithData, updateUnprocessedsWithData, @@ -778,16 +774,6 @@ async function commitSessionsAndUnprocessed(options: { }) { await channels.commitSessionsAndUnprocessed(options); } -async function getSessionById(id: string) { - const session = await channels.getSessionById(id); - - return session; -} -async function getSessionsById(id: string) { - const sessions = await channels.getSessionsById(id); - - return sessions; -} async function bulkAddSessions(array: Array) { await channels.bulkAddSessions(array); } @@ -1355,16 +1341,6 @@ async function getUnprocessedById(id: string) { return channels.getUnprocessedById(id); } -async function saveUnprocessed(data: UnprocessedType) { - const id = await channels.saveUnprocessed(_cleanData(data)); - - return id; -} - -async function saveUnprocesseds(arrayOfUnprocessed: Array) { - await channels.saveUnprocesseds(_cleanData(arrayOfUnprocessed)); -} - async function updateUnprocessedAttempts(id: string, attempts: number) { await channels.updateUnprocessedAttempts(id, attempts); } diff --git a/ts/sql/Interface.ts b/ts/sql/Interface.ts index 9fee4f2664..1362bbcd02 100644 --- a/ts/sql/Interface.ts +++ b/ts/sql/Interface.ts @@ -193,8 +193,6 @@ export type DataInterface = { sessions: Array; unprocessed: Array; }): Promise; - getSessionById: (id: string) => Promise; - getSessionsById: (conversationId: string) => Promise>; bulkAddSessions: (array: Array) => Promise; removeSessionById: (id: string) => Promise; removeSessionsByConversation: (conversationId: string) => Promise; @@ -234,10 +232,6 @@ export type DataInterface = { getUnprocessedCount: () => Promise; getAllUnprocessed: () => Promise>; - saveUnprocessed: ( - data: UnprocessedType, - options?: { forceSave?: boolean } - ) => Promise; updateUnprocessedAttempts: (id: string, attempts: number) => Promise; updateUnprocessedWithData: ( id: string, @@ -247,10 +241,6 @@ export type DataInterface = { array: Array<{ id: string; data: UnprocessedUpdateType }> ) => Promise; getUnprocessedById: (id: string) => Promise; - saveUnprocesseds: ( - arrayOfUnprocessed: Array, - options?: { forceSave?: boolean } - ) => Promise; removeUnprocessed: (id: string | Array) => Promise; removeAllUnprocessed: () => Promise; diff --git a/ts/sql/Server.ts b/ts/sql/Server.ts index 56048abdc6..90fe678934 100644 --- a/ts/sql/Server.ts +++ b/ts/sql/Server.ts @@ -135,8 +135,6 @@ const dataInterface: ServerInterface = { createOrUpdateSession, createOrUpdateSessions, commitSessionsAndUnprocessed, - getSessionById, - getSessionsById, bulkAddSessions, removeSessionById, removeSessionsByConversation, @@ -191,12 +189,10 @@ const dataInterface: ServerInterface = { getUnprocessedCount, getAllUnprocessed, - saveUnprocessed, updateUnprocessedAttempts, updateUnprocessedWithData, updateUnprocessedsWithData, getUnprocessedById, - saveUnprocesseds, removeUnprocessed, removeAllUnprocessed, @@ -2291,27 +2287,6 @@ async function commitSessionsAndUnprocessed({ })(); } -async function getSessionById(id: string): Promise { - return getById(SESSIONS_TABLE, id); -} -async function getSessionsById( - conversationId: string -): Promise> { - const db = getInstance(); - const rows: JSONRows = db - .prepare( - ` - SELECT json - FROM sessions - WHERE conversationId = $conversationId; - ` - ) - .all({ - conversationId, - }); - - return rows.map(row => jsonToObject(row.json)); -} function bulkAddSessions(array: Array): Promise { return bulkAdd(SESSIONS_TABLE, array); } @@ -4041,7 +4016,7 @@ function saveUnprocessedSync(data: UnprocessedType): string { decrypted, } = data; if (!id) { - throw new Error('saveUnprocessed: id was falsey'); + throw new Error('saveUnprocessedSync: id was falsey'); } prepare( @@ -4087,22 +4062,6 @@ function saveUnprocessedSync(data: UnprocessedType): string { return id; } -async function saveUnprocessed(data: UnprocessedType): Promise { - return saveUnprocessedSync(data); -} - -async function saveUnprocesseds( - arrayOfUnprocessed: Array -): Promise { - const db = getInstance(); - - db.transaction(() => { - for (const unprocessed of arrayOfUnprocessed) { - assertSync(saveUnprocessedSync(unprocessed)); - } - })(); -} - async function updateUnprocessedAttempts( id: string, attempts: number diff --git a/ts/test-electron/SignalProtocolStore_test.ts b/ts/test-electron/SignalProtocolStore_test.ts index 03ac9e36c1..6c0a6eb22f 100644 --- a/ts/test-electron/SignalProtocolStore_test.ts +++ b/ts/test-electron/SignalProtocolStore_test.ts @@ -1520,7 +1520,7 @@ describe('SignalProtocolStore', () => { assert.strictEqual(items[2].envelope, 'third'); }); - it('saveUnprocessed successfully updates item', async () => { + it('can updates items', async () => { const id = '1-one'; await store.addUnprocessed({ id,