Don't transcode incoming attachments
This commit is contained in:
parent
183db8a074
commit
e534dd64f2
3 changed files with 18 additions and 4 deletions
|
@ -458,7 +458,11 @@ exports.processNewAttachment = async (
|
||||||
throw new TypeError('context.logger is required');
|
throw new TypeError('context.logger is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
const rotatedAttachment = await Attachment.autoOrientJPEG(attachment);
|
const rotatedAttachment = await Attachment.autoOrientJPEG(
|
||||||
|
attachment,
|
||||||
|
undefined,
|
||||||
|
{ isIncoming: true }
|
||||||
|
);
|
||||||
const onDiskAttachment = await Attachment.migrateDataToFileSystem(
|
const onDiskAttachment = await Attachment.migrateDataToFileSystem(
|
||||||
rotatedAttachment,
|
rotatedAttachment,
|
||||||
{ writeNewAttachmentData }
|
{ writeNewAttachmentData }
|
||||||
|
|
|
@ -180,8 +180,18 @@ export function isValid(
|
||||||
export async function autoOrientJPEG(
|
export async function autoOrientJPEG(
|
||||||
attachment: AttachmentType,
|
attachment: AttachmentType,
|
||||||
_: unknown,
|
_: unknown,
|
||||||
message?: { sendHQImages?: boolean }
|
{
|
||||||
|
sendHQImages = false,
|
||||||
|
isIncoming = false,
|
||||||
|
}: {
|
||||||
|
sendHQImages?: boolean;
|
||||||
|
isIncoming?: boolean;
|
||||||
|
} = {}
|
||||||
): Promise<AttachmentType> {
|
): Promise<AttachmentType> {
|
||||||
|
if (isIncoming && !MIME.isJPEG(attachment.contentType)) {
|
||||||
|
return attachment;
|
||||||
|
}
|
||||||
|
|
||||||
if (!canBeTranscoded(attachment)) {
|
if (!canBeTranscoded(attachment)) {
|
||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +207,7 @@ export async function autoOrientJPEG(
|
||||||
);
|
);
|
||||||
const xcodedDataBlob = await scaleImageToLevel(
|
const xcodedDataBlob = await scaleImageToLevel(
|
||||||
dataBlob,
|
dataBlob,
|
||||||
message ? message.sendHQImages : false
|
sendHQImages || isIncoming
|
||||||
);
|
);
|
||||||
const xcodedDataArrayBuffer = await blobToArrayBuffer(xcodedDataBlob);
|
const xcodedDataArrayBuffer = await blobToArrayBuffer(xcodedDataBlob);
|
||||||
|
|
||||||
|
|
|
@ -3702,7 +3702,7 @@ Whisper.ConversationView = Whisper.View.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async sendStickerMessage(options: any = {}) {
|
async sendStickerMessage(options: { packId: string; stickerId: number }) {
|
||||||
const { model }: { model: ConversationModel } = this;
|
const { model }: { model: ConversationModel } = this;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue