mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-24 18:38:15 +01:00
Support voice memo backups
This commit is contained in:
@@ -20,7 +20,7 @@ import {
|
||||
isDecryptable,
|
||||
isReencryptableToSameDigest,
|
||||
} from '../../../types/Attachment';
|
||||
import { Backups } from '../../../protobuf';
|
||||
import { Backups, SignalService } from '../../../protobuf';
|
||||
import * as Bytes from '../../../Bytes';
|
||||
import { getTimestampFromLong } from '../../../util/timestampLongUtils';
|
||||
import {
|
||||
@@ -36,6 +36,7 @@ import {
|
||||
getMediaNameForAttachment,
|
||||
} from './mediaId';
|
||||
import { redactGenericText } from '../../../util/privacy';
|
||||
import { missingCaseError } from '../../../util/missingCaseError';
|
||||
|
||||
export function convertFilePointerToAttachment(
|
||||
filePointer: Backups.FilePointer
|
||||
@@ -123,6 +124,35 @@ export function convertFilePointerToAttachment(
|
||||
throw new Error('convertFilePointerToAttachment: mising locator');
|
||||
}
|
||||
|
||||
export function convertBackupMessageAttachmentToAttachment(
|
||||
messageAttachment: Backups.IMessageAttachment
|
||||
): AttachmentType | null {
|
||||
if (!messageAttachment.pointer) {
|
||||
return null;
|
||||
}
|
||||
const result = convertFilePointerToAttachment(messageAttachment.pointer);
|
||||
switch (messageAttachment.flag) {
|
||||
case Backups.MessageAttachment.Flag.VOICE_MESSAGE:
|
||||
result.flags = SignalService.AttachmentPointer.Flags.VOICE_MESSAGE;
|
||||
break;
|
||||
case Backups.MessageAttachment.Flag.BORDERLESS:
|
||||
result.flags = SignalService.AttachmentPointer.Flags.BORDERLESS;
|
||||
break;
|
||||
case Backups.MessageAttachment.Flag.GIF:
|
||||
result.flags = SignalService.AttachmentPointer.Flags.GIF;
|
||||
break;
|
||||
case Backups.MessageAttachment.Flag.NONE:
|
||||
case null:
|
||||
case undefined:
|
||||
result.flags = undefined;
|
||||
break;
|
||||
default:
|
||||
throw missingCaseError(messageAttachment.flag);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some attachments saved on desktop do not include the key used to encrypt the file
|
||||
* originally. This means that we need to encrypt the file in-memory now (at
|
||||
|
||||
Reference in New Issue
Block a user