fix: custom chat title (#534)

* Fix: Update Custom Chat Title Based on chatId

* remove `new:true` option

* Update update.ts

---------

Co-authored-by: Archer <545436317@qq.com>
This commit is contained in:
NongMO 2023-12-03 21:19:22 +08:00 committed by GitHub
parent a9ae270335
commit 7fc05af09e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,9 +13,9 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
await authChat({ req, authToken: true, chatId });
await MongoChat.findByIdAndUpdate(chatId, {
...(customTitle ? { customTitle } : {}),
...(top ? { top } : { top: null })
await MongoChat.findOneAndUpdate({ chatId }, {
...(customTitle && { customTitle }),
...(top && { top })
});
jsonRes(res);
} catch (err) {