Backup support for quotes & quoted attachments

This commit is contained in:
trevor-signal 2024-06-10 14:44:15 -04:00 committed by GitHub
parent 0f2b71b4a6
commit e0dc4c412d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 653 additions and 289 deletions

View file

@ -6,6 +6,7 @@ import type { ConversationModel } from '../models/conversations';
import type {
CustomError,
MessageAttributesType,
QuotedAttachmentType,
QuotedMessageType,
} from '../model-types.d';
import type { ServiceIdString } from '../types/ServiceId';
@ -136,6 +137,31 @@ export function isQuoteAMatch(
);
}
export const shouldTryToCopyFromQuotedMessage = ({
referencedMessageNotFound,
quoteAttachment,
}: {
referencedMessageNotFound: boolean;
quoteAttachment: QuotedAttachmentType | undefined;
}): boolean => {
// If we've tried and can't find the message, try again.
if (referencedMessageNotFound === true) {
return true;
}
// Otherwise, try again in case we have not yet copied over the thumbnail from the
// original attachment (maybe it had not been downloaded when we first checked)
if (!quoteAttachment?.thumbnail) {
return false;
}
if (quoteAttachment.thumbnail.copied === true) {
return false;
}
return true;
};
export function getAuthorId(
message: Pick<MessageAttributesType, 'type' | 'source' | 'sourceServiceId'>
): string | undefined {