Send and properly receive AttachmentPointer.uploadTimestamp

This commit is contained in:
trevor-signal 2025-05-13 15:29:10 -04:00 committed by GitHub
commit ba015a779e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 60 additions and 8 deletions

View file

@ -49,22 +49,48 @@ export function processAttachment(
export function processAttachment(
attachment?: Proto.IAttachmentPointer | null
): ProcessedAttachment | undefined {
if (!attachment) {
const attachmentWithoutNulls = shallowDropNull(attachment);
if (!attachmentWithoutNulls) {
return undefined;
}
const { cdnId } = attachment;
const {
cdnId,
cdnKey,
cdnNumber,
clientUuid,
key,
size,
contentType,
digest,
incrementalMac,
chunkSize,
fileName,
flags,
width,
height,
caption,
blurHash,
uploadTimestamp,
} = attachmentWithoutNulls;
const hasCdnId = Long.isLong(cdnId) ? !cdnId.isZero() : Boolean(cdnId);
const { clientUuid, contentType, digest, incrementalMac, key, size } =
attachment;
if (!isNumber(size)) {
throw new Error('Missing size on incoming attachment!');
}
return {
...shallowDropNull(attachment),
cdnKey,
cdnNumber,
chunkSize,
fileName,
flags,
width,
height,
caption,
blurHash,
uploadTimestamp: uploadTimestamp?.toNumber(),
cdnId: hasCdnId ? String(cdnId) : undefined,
clientUuid: Bytes.isNotEmpty(clientUuid)
? bytesToUuid(clientUuid)