Allow incremental playback for attachments with plaintextHash

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2026-03-24 17:40:26 -05:00
committed by GitHub
parent cd979c031a
commit 230b04b7f0
2 changed files with 36 additions and 12 deletions

View File

@@ -27,6 +27,7 @@ export function getLocalAttachmentUrl(
AttachmentType,
| 'contentType'
| 'digest'
| 'plaintextHash'
| 'downloadPath'
| 'incrementalMac'
| 'chunkSize'
@@ -87,10 +88,17 @@ export function getLocalAttachmentUrl(
}
url.searchParams.set('key', attachment.key);
if (!attachment.digest) {
throw new Error('getLocalAttachmentUrl: Missing attachment digest!');
// Attachments restored from backup / link & sync may have plaintextHash but not
// digest
if (attachment.plaintextHash) {
url.searchParams.set('plaintextHash', attachment.plaintextHash);
} else if (attachment.digest) {
url.searchParams.set('digest', attachment.digest);
} else {
throw new Error(
'getLocalAttachmentUrl: Missing attachment plaintextHash and digest!'
);
}
url.searchParams.set('digest', attachment.digest);
if (!attachment.incrementalMac) {
throw new Error(