Add CallLinkDeleteManager to retry and ensure deletion

This commit is contained in:
ayumi-signal 2024-09-16 12:22:01 -07:00 committed by GitHub
parent 8b627b3f1a
commit a40d54099c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 229 additions and 89 deletions

View file

@ -586,7 +586,7 @@ type ReadableInterface = {
getCallLinkByRoomId: (roomId: string) => CallLinkType | undefined;
getCallLinkRecordByRoomId: (roomId: string) => CallLinkRecord | undefined;
getAllCallLinkRecordsWithAdminKey(): ReadonlyArray<CallLinkRecord>;
getAllMarkedDeletedCallLinks(): ReadonlyArray<CallLinkType>;
getAllMarkedDeletedCallLinkRoomIds(): ReadonlyArray<string>;
getMessagesBetween: (
conversationId: string,
options: GetMessagesBetweenOptions

View file

@ -181,7 +181,7 @@ import {
updateCallLinkState,
beginDeleteAllCallLinks,
getAllCallLinkRecordsWithAdminKey,
getAllMarkedDeletedCallLinks,
getAllMarkedDeletedCallLinkRoomIds,
finalizeDeleteCallLink,
beginDeleteCallLink,
deleteCallLinkFromSync,
@ -313,7 +313,7 @@ export const DataReader: ServerReadableInterface = {
getCallLinkByRoomId,
getCallLinkRecordByRoomId,
getAllCallLinkRecordsWithAdminKey,
getAllMarkedDeletedCallLinks,
getAllMarkedDeletedCallLinkRoomIds,
getMessagesBetween,
getNearbyMessageFromDeletedSet,
getMostRecentAddressableMessages,

View file

@ -305,16 +305,13 @@ export function getAllCallLinkRecordsWithAdminKey(
.map(item => callLinkRecordSchema.parse(item));
}
export function getAllMarkedDeletedCallLinks(
export function getAllMarkedDeletedCallLinkRoomIds(
db: ReadableDB
): ReadonlyArray<CallLinkType> {
): ReadonlyArray<string> {
const [query] = sql`
SELECT * FROM callLinks WHERE deleted = 1;
SELECT roomId FROM callLinks WHERE deleted = 1;
`;
return db
.prepare(query)
.all()
.map(item => callLinkFromRecord(callLinkRecordSchema.parse(item)));
return db.prepare(query).pluck().all();
}
// TODO: Run this after uploading storage records, maybe periodically on startup