v4.2.2 (#312)
This commit is contained in:
@@ -18,7 +18,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
throw new Error('最多 10 组 API 秘钥');
|
||||
}
|
||||
|
||||
const apiKey = `fastgpt-${nanoid()}`;
|
||||
const apiKey = `${global.systemEnv?.openapiPrefix || 'fastgpt'}-${nanoid()}`;
|
||||
|
||||
await OpenApi.create({
|
||||
userId,
|
||||
|
||||
@@ -116,7 +116,7 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex
|
||||
appId,
|
||||
userId
|
||||
}),
|
||||
getChatHistory({ chatId, userId })
|
||||
getChatHistory({ chatId, appId, userId })
|
||||
]);
|
||||
|
||||
const isOwner = !shareId && userId === String(app.userId);
|
||||
|
||||
@@ -7,6 +7,7 @@ import { Types } from 'mongoose';
|
||||
import type { ChatItemType } from '@/types/chat';
|
||||
|
||||
export type Props = {
|
||||
appId?: string;
|
||||
chatId?: string;
|
||||
limit?: number;
|
||||
};
|
||||
@@ -36,9 +37,10 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
export async function getChatHistory({
|
||||
chatId,
|
||||
userId,
|
||||
appId,
|
||||
limit = 30
|
||||
}: Props & { userId: string }): Promise<Response> {
|
||||
if (!chatId) {
|
||||
if (!chatId || !appId) {
|
||||
return { history: [] };
|
||||
}
|
||||
|
||||
@@ -46,6 +48,7 @@ export async function getChatHistory({
|
||||
{
|
||||
$match: {
|
||||
chatId,
|
||||
appId: new Types.ObjectId(appId),
|
||||
userId: new Types.ObjectId(userId)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user