From 6c93b672c458fea4be3a41cbeaea94e8440e27cc Mon Sep 17 00:00:00 2001 From: Giovanni Troisi Date: Wed, 22 Jan 2025 15:55:32 +0100 Subject: [PATCH] removed default value for slug in faq_kb model removed slug after publish --- models/faq_kb.js | 1 - routes/faq_kb.js | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/models/faq_kb.js b/models/faq_kb.js index f4b93cb6a33..925003c885c 100644 --- a/models/faq_kb.js +++ b/models/faq_kb.js @@ -125,7 +125,6 @@ var Faq_kbSchema = new Schema({ slug: { type: String, required: false, - default: "", index: true }, },{ diff --git a/routes/faq_kb.js b/routes/faq_kb.js index fe126a75fff..98dc3426847 100644 --- a/routes/faq_kb.js +++ b/routes/faq_kb.js @@ -245,7 +245,7 @@ router.put('/:faq_kbid/publish', roleChecker.hasRole('admin'), async (req, res) let forkedChatBotId = forked.bot_id; winston.debug("forkedChatBotId: "+forkedChatBotId); - let updatedForkedChabot = await Faq_kb.findByIdAndUpdate(forkedChatBotId, {trashed: true, publishedBy: req.user.id, publishedAt: new Date().getTime()}, { new: true, upsert: true }).exec(); + let updatedForkedChabot = await Faq_kb.findByIdAndUpdate(forkedChatBotId, { $unset: { slug: 1 }, trashed: true, publishedBy: req.user.id, publishedAt: new Date().getTime()}, { new: true, upsert: true }).exec(); winston.debug("updatedForkedChabot: ",updatedForkedChabot); botEvent.emit('faqbot.update', updatedForkedChabot);