From 59ddf09b943651d7062d90792603bc6da83e91c8 Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Tue, 30 May 2023 00:40:03 +0800 Subject: [PATCH] fix: save chat --- src/pages/api/chat/saveChat.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/pages/api/chat/saveChat.ts b/src/pages/api/chat/saveChat.ts index 542a03ab6..5a9736bbc 100644 --- a/src/pages/api/chat/saveChat.ts +++ b/src/pages/api/chat/saveChat.ts @@ -51,7 +51,7 @@ export async function saveChat({ userId }: Props & { userId: string }) { await connectToDatabase(); - await authModel({ modelId, userId, authOwner: false }); + const { model } = await authModel({ modelId, userId, authOwner: false }); const content = prompts.map((item) => ({ _id: item._id ? new mongoose.Types.ObjectId(item._id) : undefined, @@ -89,9 +89,14 @@ export async function saveChat({ latestChat: content[1].value }).then((res) => res._id) ]), - Model.findByIdAndUpdate(modelId, { - updateTime: new Date() - }) // update model + // update model + ...(String(model.userId) === userId + ? [ + Model.findByIdAndUpdate(modelId, { + updateTime: new Date() + }) + ] + : []) ]); return {