perf: completion chatId
This commit is contained in:
@@ -9,7 +9,7 @@ const nanoid = customAlphabet('abcdefghijklmnopqrstuvwxyz1234567890', 24);
|
||||
/* create a shareChat */
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
const { appId, name, maxContext } = req.body as ShareChatEditType & {
|
||||
const { appId, name } = req.body as ShareChatEditType & {
|
||||
appId: string;
|
||||
};
|
||||
|
||||
@@ -27,8 +27,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
shareId,
|
||||
userId,
|
||||
appId,
|
||||
name,
|
||||
maxContext
|
||||
name
|
||||
});
|
||||
|
||||
jsonRes(res, {
|
||||
|
||||
@@ -3,10 +3,7 @@ import { jsonRes } from '@/service/response';
|
||||
import { connectToDatabase, ShareChat, User } from '@/service/mongo';
|
||||
import type { InitShareChatResponse } from '@/api/response/chat';
|
||||
import { authApp } from '@/service/utils/auth';
|
||||
import { hashPassword } from '@/service/utils/tools';
|
||||
import { HUMAN_ICON } from '@/constants/chat';
|
||||
import { FlowModuleTypeEnum } from '@/constants/flow';
|
||||
import { SystemInputEnum } from '@/constants/app';
|
||||
import { getSpecialModule } from '@/components/ChatBox';
|
||||
|
||||
/* 初始化我的聊天框,需要身份验证 */
|
||||
@@ -33,21 +30,18 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
}
|
||||
|
||||
// 校验使用权限
|
||||
const { app } = await authApp({
|
||||
appId: shareChat.appId,
|
||||
userId: String(shareChat.userId),
|
||||
authOwner: false
|
||||
});
|
||||
|
||||
const user = await User.findById(shareChat.userId, 'avatar');
|
||||
const [{ app }, user] = await Promise.all([
|
||||
authApp({
|
||||
appId: shareChat.appId,
|
||||
userId: String(shareChat.userId),
|
||||
authOwner: false
|
||||
}),
|
||||
User.findById(shareChat.userId, 'avatar')
|
||||
]);
|
||||
|
||||
jsonRes<InitShareChatResponse>(res, {
|
||||
data: {
|
||||
userAvatar: user?.avatar || HUMAN_ICON,
|
||||
maxContext:
|
||||
app.modules
|
||||
?.find((item) => item.flowType === FlowModuleTypeEnum.historyNode)
|
||||
?.inputs?.find((item) => item.key === 'maxContext')?.value || 0,
|
||||
app: {
|
||||
...getSpecialModule(app.modules),
|
||||
name: app.name,
|
||||
|
||||
@@ -28,7 +28,6 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
|
||||
shareId: item.shareId,
|
||||
name: item.name,
|
||||
total: item.total,
|
||||
maxContext: item.maxContext,
|
||||
lastTime: item.lastTime
|
||||
}))
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user