fix: do not deleted quoted message attachments on quote delete

pull/3281/head
Audric Ackermann 10 months ago
parent 5e67f6a424
commit d55b88790f
No known key found for this signature in database

@ -421,7 +421,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
/**
* Remove from the DB all the attachments linked to that message.
* Note: does not commit the changes to the DB, on purpose.
* When we cleanup(), we always want to remove the message afterwards. So no commit() are done at all.
* When we cleanup(), we always want to remove the message afterwards. So no commit() calls are made.
*
*/
public async cleanup() {

@ -23,7 +23,7 @@ export const deleteExternalMessageFiles = async (messageAttributes: {
preview: Array<any> | undefined;
}) => {
let anyChanges = false;
const { attachments, quote, preview } = messageAttributes;
const { attachments, preview } = messageAttributes;
if (attachments && attachments.length) {
await Promise.all(attachments.map(deleteData));
@ -46,27 +46,6 @@ export const deleteExternalMessageFiles = async (messageAttributes: {
}
}
if (quote && quote.attachments && quote.attachments.length) {
await Promise.all(
quote.attachments.map(async (_attachment: { thumbnail: any }) => {
const attachment = _attachment;
const { thumbnail } = attachment;
// To prevent spoofing, we copy the original image from the quoted message.
// If so, it will have a 'copied' field. We don't want to delete it if it has
// that field set to true.
if (thumbnail && thumbnail.path && !thumbnail.copied) {
await deleteOnDisk(thumbnail.path);
}
attachment.thumbnail = undefined;
anyChanges = true;
return attachment;
})
);
}
if (preview && preview.length) {
await Promise.all(
preview.map(async (_item: { image: any }) => {

Loading…
Cancel
Save