Support voice memo backups

This commit is contained in:
trevor-signal 2024-06-06 12:16:27 -04:00 committed by GitHub
parent 348503c7f9
commit 9cbbbe0ef0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 82 additions and 19 deletions

View file

@ -13,10 +13,11 @@ import { ReadStatus } from '../../messages/MessageReadStatus';
import { SeenStatus } from '../../MessageSeenStatus';
import { loadCallsHistory } from '../../services/callHistoryLoader';
import { setupBasics, asymmetricRoundtripHarness } from './helpers';
import { IMAGE_JPEG } from '../../types/MIME';
import { AUDIO_MP3, IMAGE_JPEG } from '../../types/MIME';
import type { MessageAttributesType } from '../../model-types';
import type { AttachmentType } from '../../types/Attachment';
import { isVoiceMessage, type AttachmentType } from '../../types/Attachment';
import { strictAssert } from '../../util/assert';
import { SignalService } from '../../protobuf';
const CONTACT_A = generateAci();
@ -129,6 +130,33 @@ describe('backup/attachments', () => {
BackupLevel.Media
);
});
it('roundtrips voice message attachments', async () => {
const attachment = composeAttachment(1);
attachment.contentType = AUDIO_MP3;
attachment.flags = SignalService.AttachmentPointer.Flags.VOICE_MESSAGE;
strictAssert(isVoiceMessage(attachment), 'it is a voice attachment');
strictAssert(attachment.digest, 'digest exists');
await asymmetricRoundtripHarness(
[
composeMessage(1, {
attachments: [attachment],
}),
],
[
composeMessage(1, {
attachments: [
{
...omit(attachment, ['path', 'iv', 'uploadTimestamp']),
backupLocator: { mediaName: attachment.digest },
},
],
}),
],
BackupLevel.Media
);
});
});
describe('Preview attachments', () => {