Fix call history deletion from sync messages

This commit is contained in:
Jamie Kyle 2023-09-27 12:42:30 -07:00 committed by GitHub
parent 20ddca9684
commit 1cc478180e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 84 additions and 11 deletions

View file

@ -305,6 +305,7 @@ const dataInterface: ServerInterface = {
getLastConversationMessage,
getAllCallHistory,
clearCallHistory,
cleanupCallHistoryMessages,
getCallHistoryUnreadCount,
markCallHistoryRead,
markAllCallHistoryRead,
@ -3294,6 +3295,24 @@ async function clearCallHistory(
})();
}
async function cleanupCallHistoryMessages(): Promise<void> {
const db = getInstance();
return db
.transaction(() => {
const [query, params] = sql`
DELETE FROM messages
WHERE messages.id IN (
SELECT messages.id FROM messages
LEFT JOIN callsHistory ON callsHistory.callId IS messages.callId
WHERE messages.type IS 'call-history'
AND callsHistory.status IS ${CALL_STATUS_DELETED}
)
`;
db.prepare(query).run(params);
})
.immediate();
}
async function getCallHistoryMessageByCallId(options: {
conversationId: string;
callId: string;