From 75073a64fb9fb7a32dc75dd4fe53d0267bb7f30d Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Fri, 28 Apr 2023 13:21:56 +0800 Subject: [PATCH] fix: chat window auth --- src/pages/api/chat/init.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 } },