Receive support for editing messages
This commit is contained in:
parent
2781e621ad
commit
36e21c0134
46 changed files with 2053 additions and 405 deletions
|
@ -21,31 +21,12 @@ export function hasAttachmentDownloads(
|
|||
return true;
|
||||
}
|
||||
|
||||
const hasNormalAttachments = normalAttachments.some(attachment => {
|
||||
if (!attachment) {
|
||||
return false;
|
||||
}
|
||||
// We've already downloaded this!
|
||||
if (attachment.path) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
const hasNormalAttachments = hasNormalAttachmentDownloads(normalAttachments);
|
||||
if (hasNormalAttachments) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const previews = message.preview || [];
|
||||
const hasPreviews = previews.some(item => {
|
||||
if (!item.image) {
|
||||
return false;
|
||||
}
|
||||
// We've already downloaded this!
|
||||
if (item.image.path) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
const hasPreviews = hasPreviewDownloads(message.preview);
|
||||
if (hasPreviews) {
|
||||
return true;
|
||||
}
|
||||
|
@ -85,5 +66,48 @@ export function hasAttachmentDownloads(
|
|||
return !sticker.data || (sticker.data && !sticker.data.path);
|
||||
}
|
||||
|
||||
const { editHistory } = message;
|
||||
if (editHistory) {
|
||||
const hasAttachmentsWithinEditHistory = editHistory.some(
|
||||
edit =>
|
||||
hasNormalAttachmentDownloads(edit.attachments) ||
|
||||
hasPreviewDownloads(edit.preview)
|
||||
);
|
||||
|
||||
if (hasAttachmentsWithinEditHistory) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function hasPreviewDownloads(
|
||||
previews: MessageAttributesType['preview']
|
||||
): boolean {
|
||||
return (previews || []).some(item => {
|
||||
if (!item.image) {
|
||||
return false;
|
||||
}
|
||||
// We've already downloaded this!
|
||||
if (item.image.path) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
function hasNormalAttachmentDownloads(
|
||||
attachments: MessageAttributesType['attachments']
|
||||
): boolean {
|
||||
return (attachments || []).some(attachment => {
|
||||
if (!attachment) {
|
||||
return false;
|
||||
}
|
||||
// We've already downloaded this!
|
||||
if (attachment.path) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue