From 024a3521e13e73801d60e4106c11f7f869084c4d Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Wed, 22 Sep 2021 11:15:48 -0700 Subject: [PATCH] Fix quote content-type for GIFs --- ts/models/conversations.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index af7362302f1..f50eac04549 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -14,7 +14,7 @@ import { VerificationOptions, WhatIsThis, } from '../model-types.d'; -import { AttachmentType } from '../types/Attachment'; +import { AttachmentType, isGIF } from '../types/Attachment'; import { CallMode, CallHistoryDetailsType } from '../types/Calling'; import * as Stickers from '../types/Stickers'; import { CapabilityError } from '../types/errors'; @@ -38,7 +38,7 @@ import { isConversationUnregistered } from '../util/isConversationUnregistered'; import { missingCaseError } from '../util/missingCaseError'; import { sniffImageMimeType } from '../util/sniffImageMimeType'; import { isValidE164 } from '../util/isValidE164'; -import { MIMEType, IMAGE_WEBP } from '../types/MIME'; +import { MIMEType, IMAGE_JPEG, IMAGE_GIF, IMAGE_WEBP } from '../types/MIME'; import { UUID } from '../types/UUID'; import { arrayBufferToBase64, @@ -3148,14 +3148,15 @@ export class ConversationModel extends window.Backbone attachments, attachment => attachment && !attachment.pending && !attachment.error ); - const attachmentsToUse = take(validAttachments, 1); + const attachmentsToUse = Array.from(take(validAttachments, 1)); + const isGIFQuote = isGIF(attachmentsToUse); return Promise.all( map(attachmentsToUse, async attachment => { const { fileName, thumbnail, contentType } = attachment; return { - contentType, + contentType: isGIFQuote ? IMAGE_GIF : contentType, // Our protos library complains about this field being undefined, so we force // it to null fileName: fileName || null, @@ -3233,7 +3234,7 @@ export class ConversationModel extends window.Backbone return { authorUuid: contact.get('uuid'), attachments: isTapToView(quotedMessage.attributes) - ? [{ contentType: 'image/jpeg', fileName: null }] + ? [{ contentType: IMAGE_JPEG, fileName: null }] : await this.getQuoteAttachment(attachments, preview, sticker), bodyRanges: quotedMessage.get('bodyRanges'), id: quotedMessage.get('sent_at'),