Update attachment handling
This commit is contained in:
parent
6f7faf4be8
commit
6c348e2db7
4 changed files with 34 additions and 22 deletions
|
@ -5,7 +5,7 @@ import * as Bytes from '../Bytes';
|
|||
import type { AttachmentDownloadJobTypeType } from '../types/AttachmentDownload';
|
||||
|
||||
import type { AttachmentType } from '../types/Attachment';
|
||||
import { getAttachmentSignature, isDownloaded } from '../types/Attachment';
|
||||
import { getAttachmentSignatureSafe, isDownloaded } from '../types/Attachment';
|
||||
import { __DEPRECATED$getMessageById } from '../messages/getMessageById';
|
||||
|
||||
export async function addAttachmentToMessage(
|
||||
|
@ -21,7 +21,10 @@ export async function addAttachmentToMessage(
|
|||
return;
|
||||
}
|
||||
|
||||
const attachmentSignature = getAttachmentSignature(attachment);
|
||||
const attachmentSignature = getAttachmentSignatureSafe(attachment);
|
||||
if (!attachmentSignature) {
|
||||
log.error(`${logPrefix}: Attachment did not have valid signature (digest)`);
|
||||
}
|
||||
|
||||
if (type === 'long-message') {
|
||||
let handledAnywhere = false;
|
||||
|
@ -45,7 +48,8 @@ export async function addAttachmentToMessage(
|
|||
}
|
||||
// This attachment isn't destined for this edit
|
||||
if (
|
||||
getAttachmentSignature(edit.bodyAttachment) !== attachmentSignature
|
||||
getAttachmentSignatureSafe(edit.bodyAttachment) !==
|
||||
attachmentSignature
|
||||
) {
|
||||
return edit;
|
||||
}
|
||||
|
@ -79,7 +83,8 @@ export async function addAttachmentToMessage(
|
|||
return;
|
||||
}
|
||||
if (
|
||||
getAttachmentSignature(existingBodyAttachment) !== attachmentSignature
|
||||
getAttachmentSignatureSafe(existingBodyAttachment) !==
|
||||
attachmentSignature
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
@ -116,7 +121,7 @@ export async function addAttachmentToMessage(
|
|||
return existing;
|
||||
}
|
||||
|
||||
if (attachmentSignature !== getAttachmentSignature(existing)) {
|
||||
if (attachmentSignature !== getAttachmentSignatureSafe(existing)) {
|
||||
return existing;
|
||||
}
|
||||
|
||||
|
@ -322,7 +327,7 @@ export async function addAttachmentToMessage(
|
|||
message.set({
|
||||
sticker: {
|
||||
...sticker,
|
||||
data: attachment,
|
||||
data: sticker.data ? maybeReplaceAttachment(sticker.data) : attachment,
|
||||
},
|
||||
});
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue