fix: chatgptBrowser handling and ask.js refactor

This commit is contained in:
Daniel Avila 2023-03-28 22:28:43 -04:00
parent 005d8fb178
commit 0d7300be9b
4 changed files with 39 additions and 92 deletions

View file

@ -43,9 +43,15 @@ module.exports = {
return { message: 'Error saving conversation' };
}
},
updateConvo: async (user, { conversationId, ...update }) => {
updateConvo: async (user, { conversationId, oldConvoId, ...update }) => {
try {
return await Conversation.findOneAndUpdate({ conversationId: conversationId, user }, update, {
let convoId = conversationId;
if (oldConvoId) {
convoId = oldConvoId;
update.conversationId = conversationId;
}
return await Conversation.findOneAndUpdate({ conversationId: convoId, user }, update, {
new: true
}).exec();
} catch (error) {