Support for single-attachment delete synced across devices

This commit is contained in:
Scott Nonnenberg 2024-06-21 15:35:18 -07:00 committed by GitHub
parent 97229e2e65
commit ac04d02d4f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 422 additions and 55 deletions

View file

@ -156,6 +156,7 @@ import { getCallEventForProto } from '../util/callDisposition';
import { checkOurPniIdentityKey } from '../util/checkOurPniIdentityKey';
import { CallLogEvent } from '../types/CallDisposition';
import { CallLinkUpdateSyncType } from '../types/CallLink';
import { bytesToUuid } from '../util/uuidToBytes';
const GROUPV2_ID_LENGTH = 32;
const RETRY_TIMEOUT = 2 * 60 * 1000;
@ -3761,6 +3762,67 @@ export default class MessageReceiver
eventData = eventData.concat(localOnlyConversationDeletes);
}
if (deleteSync.attachmentDeletes?.length) {
const attachmentDeletes: Array<DeleteForMeSyncTarget> =
deleteSync.attachmentDeletes
.map(item => {
const {
clientUuid: targetClientUuid,
conversation: targetConversation,
fallbackDigest: targetFallbackDigest,
fallbackPlaintextHash: targetFallbackPlaintextHash,
targetMessage,
} = item;
const conversation = targetConversation
? processConversationToDelete(targetConversation, logId)
: undefined;
const message = targetMessage
? processMessageToDelete(targetMessage, logId)
: undefined;
if (!conversation) {
log.warn(
`${logId}/handleDeleteForMeSync/attachmentDeletes: No target conversation`
);
return undefined;
}
if (!message) {
log.warn(
`${logId}/handleDeleteForMeSync/attachmentDeletes: No target message`
);
return undefined;
}
const clientUuid = targetClientUuid?.length
? bytesToUuid(targetClientUuid)
: undefined;
const fallbackDigest = targetFallbackDigest?.length
? Bytes.toBase64(targetFallbackDigest)
: undefined;
// TODO: DESKTOP-7204
const fallbackPlaintextHash = targetFallbackPlaintextHash?.length
? Bytes.toHex(targetFallbackPlaintextHash)
: undefined;
if (!clientUuid && !fallbackDigest && !fallbackPlaintextHash) {
log.warn(
`${logId}/handleDeleteForMeSync/attachmentDeletes: Missing clientUuid, fallbackDigest and fallbackPlaintextHash`
);
return undefined;
}
return {
type: 'delete-single-attachment' as const,
conversation,
message,
clientUuid,
fallbackDigest,
fallbackPlaintextHash,
timestamp,
};
})
.filter(isNotNil);
eventData = eventData.concat(attachmentDeletes);
}
if (!eventData.length) {
throw new Error(`${logId}: Nothing found in sync message!`);
}