Commit 59ddf09b by archer

fix: save chat

parent cdee91be
...@@ -51,7 +51,7 @@ export async function saveChat({ ...@@ -51,7 +51,7 @@ export async function saveChat({
userId userId
}: Props & { userId: string }) { }: Props & { userId: string }) {
await connectToDatabase(); await connectToDatabase();
await authModel({ modelId, userId, authOwner: false }); const { model } = await authModel({ modelId, userId, authOwner: false });
const content = prompts.map((item) => ({ const content = prompts.map((item) => ({
_id: item._id ? new mongoose.Types.ObjectId(item._id) : undefined, _id: item._id ? new mongoose.Types.ObjectId(item._id) : undefined,
...@@ -89,9 +89,14 @@ export async function saveChat({ ...@@ -89,9 +89,14 @@ export async function saveChat({
latestChat: content[1].value latestChat: content[1].value
}).then((res) => res._id) }).then((res) => res._id)
]), ]),
Model.findByIdAndUpdate(modelId, { // update model
updateTime: new Date() ...(String(model.userId) === userId
}) // update model ? [
Model.findByIdAndUpdate(modelId, {
updateTime: new Date()
})
]
: [])
]); ]);
return { return {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment