diff --git a/src/pages/api/chat/init.ts b/src/pages/api/chat/init.ts index 29740c2dd..f44bc42da 100644 --- a/src/pages/api/chat/init.ts +++ b/src/pages/api/chat/init.ts @@ -30,7 +30,12 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) if (chatId) { // 获取 chat.content 数据 history = await Chat.aggregate([ - { $match: { _id: new mongoose.Types.ObjectId(chatId) } }, + { + $match: { + _id: new mongoose.Types.ObjectId(chatId), + userId: new mongoose.Types.ObjectId(userId) + } + }, { $unwind: '$content' }, { $match: { 'content.deleted': false } }, { $sort: { 'content._id': -1 } },