mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
fix: remove related messages when deleting conversations.
This commit is contained in:
parent
0d7300be9b
commit
e796a19136
1 changed files with 4 additions and 3 deletions
|
|
@ -149,9 +149,10 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteConvos: async (user, filter) => {
|
deleteConvos: async (user, filter) => {
|
||||||
|
let toRemove = await Conversation.find({...filter, user}).select('conversationId')
|
||||||
|
const ids = toRemove.map(instance => instance.conversationId);
|
||||||
let deleteCount = await Conversation.deleteMany({...filter, user}).exec();
|
let deleteCount = await Conversation.deleteMany({...filter, user}).exec();
|
||||||
console.log('deleteCount', deleteCount);
|
deleteCount.messages = await deleteMessages({conversationId: {$in: ids}});
|
||||||
deleteCount.messages = await deleteMessages({ ...filter, user });
|
|
||||||
return deleteCount;
|
return deleteCount;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue