This commit is contained in:
archer
2023-07-18 11:50:16 +08:00
parent f9d83c481f
commit 505aff3dbf
26 changed files with 216 additions and 210 deletions

View File

@@ -27,7 +27,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
_id: item._id,
updateTime: item.updateTime,
appId: item.appId,
title: item.customTitle || item.title,
customTitle: item.customTitle,
title: item.title,
top: item.top
}))
});

View File

@@ -7,22 +7,22 @@ import { rawSearchKey } from '@/constants/chat';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const { historyId, contentId } = req.query as {
historyId: string;
const { chatId, contentId } = req.query as {
chatId: string;
contentId: string;
};
await connectToDatabase();
const { userId } = await authUser({ req, authToken: true });
if (!historyId || !contentId) {
if (!chatId || !contentId) {
throw new Error('params is error');
}
const history = await Chat.aggregate([
{
$match: {
_id: new Types.ObjectId(historyId),
_id: new Types.ObjectId(chatId),
userId: new Types.ObjectId(userId)
}
},

View File

@@ -4,7 +4,7 @@ import { connectToDatabase, Chat } from '@/service/mongo';
import { authUser } from '@/service/utils/auth';
export type Props = {
historyId: string;
chatId: string;
customTitle?: string;
top?: boolean;
};
@@ -12,7 +12,7 @@ export type Props = {
/* 更新聊天标题 */
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
const { historyId, customTitle, top } = req.body as Props;
const { chatId, customTitle, top } = req.body as Props;
const { userId } = await authUser({ req, authToken: true });
@@ -20,7 +20,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
await Chat.findOneAndUpdate(
{
_id: historyId,
_id: chatId,
userId
},
{

View File

@@ -7,12 +7,12 @@ import { Types } from 'mongoose';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
try {
let {
historyId,
chatId,
contentId,
quoteId,
sourceText = ''
} = req.body as {
historyId: string;
chatId: string;
contentId: string;
quoteId: string;
sourceText: string;
@@ -21,13 +21,13 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
const { userId } = await authUser({ req, authToken: true });
if (!contentId || !historyId || !quoteId) {
if (!contentId || !chatId || !quoteId) {
throw new Error('params is error');
}
await Chat.updateOne(
{
_id: new Types.ObjectId(historyId),
_id: new Types.ObjectId(chatId),
userId: new Types.ObjectId(userId),
'content._id': new Types.ObjectId(contentId)
},