Fix storage mergeCallLinkRecord deletedAt handling

Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2024-10-15 21:28:50 -05:00 committed by GitHub
parent 6cc07a4d17
commit c068cb7bd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1974,14 +1974,16 @@ export async function mergeCallLinkRecord(
const localCallLinkDbRecord = const localCallLinkDbRecord =
await DataReader.getCallLinkRecordByRoomId(roomId); await DataReader.getCallLinkRecordByRoomId(roomId);
const deletedAt: number | null = // Note deletedAtTimestampMs can be 0
callLinkRecord.deletedAtTimestampMs != null const deletedAtTimestampMs = callLinkRecord.deletedAtTimestampMs?.toNumber();
? getTimestampFromLong(callLinkRecord.deletedAtTimestampMs) const deletedAt = deletedAtTimestampMs || null;
: null; const shouldDrop = Boolean(
const shouldDrop = deletedAt && isOlderThan(deletedAt, getMessageQueueTime())
deletedAt != null && isOlderThan(deletedAt, getMessageQueueTime()); );
if (shouldDrop) { if (shouldDrop) {
details.push('expired deleted call link; scheduling for removal'); details.push(
`expired deleted call link deletedAt=${deletedAt}; scheduling for removal`
);
} }
const callLinkDbRecord: CallLinkRecord = { const callLinkDbRecord: CallLinkRecord = {
@ -2005,7 +2007,9 @@ export async function mergeCallLinkRecord(
if (!localCallLinkDbRecord) { if (!localCallLinkDbRecord) {
if (deletedAt) { if (deletedAt) {
details.push('skipping deleted call link with no matching local record'); details.push(
`skipping deleted call link with no matching local record deletedAt=${deletedAt}`
);
} else if (await DataReader.defunctCallLinkExists(roomId)) { } else if (await DataReader.defunctCallLinkExists(roomId)) {
details.push('skipping known defunct call link'); details.push('skipping known defunct call link');
} else { } else {
@ -2022,7 +2026,7 @@ export async function mergeCallLinkRecord(
storageID: callLink.storageID, storageID: callLink.storageID,
storageVersion: callLink.storageVersion, storageVersion: callLink.storageVersion,
storageUnknownFields: callLink.storageUnknownFields, storageUnknownFields: callLink.storageUnknownFields,
source: 'storage.mergeCallLinkRecord', source: `storage.mergeCallLinkRecord(${redactedStorageID})`,
}) })
); );
} }