mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 18:48:55 +00:00
4.8.10 test (#2401)
* perf: i18n * perf: i18n and img tip * perf: readme * perf: hide tool ai response * fix: copy app * fix: parse image url regx * perf: folder collection forbid update
This commit is contained in:
@@ -39,6 +39,7 @@ async function handler(
|
||||
type: app.type,
|
||||
modules: app.modules,
|
||||
edges: app.edges,
|
||||
chatConfig: app.chatConfig,
|
||||
teamId: app.teamId,
|
||||
tmbId,
|
||||
pluginData: app.pluginData
|
||||
|
@@ -5,6 +5,10 @@ import { NextAPI } from '@/service/middleware/entry';
|
||||
import { WritePermissionVal } from '@fastgpt/global/support/permission/constant';
|
||||
import { CommonErrEnum } from '@fastgpt/global/common/error/code/common';
|
||||
import { ApiRequestProps } from '@fastgpt/service/type/next';
|
||||
import { DatasetCollectionTypeEnum } from '@fastgpt/global/core/dataset/constants';
|
||||
import { ClientSession } from '@fastgpt/service/common/mongo';
|
||||
import { CollectionWithDatasetType } from '@fastgpt/global/core/dataset/type';
|
||||
import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
|
||||
|
||||
export type UpdateDatasetCollectionParams = {
|
||||
id: string;
|
||||
@@ -14,6 +18,52 @@ export type UpdateDatasetCollectionParams = {
|
||||
forbid?: boolean;
|
||||
};
|
||||
|
||||
// Set folder collection children forbid status
|
||||
const updateFolderChildrenForbid = async ({
|
||||
collection,
|
||||
forbid,
|
||||
session
|
||||
}: {
|
||||
collection: CollectionWithDatasetType;
|
||||
forbid: boolean;
|
||||
session: ClientSession;
|
||||
}) => {
|
||||
// 从 collection 作为 parent 进行递归查找,找到它所有 forbid 与它相同的 child
|
||||
const find = async (parentId: string): Promise<string[]> => {
|
||||
const children = await MongoDatasetCollection.find(
|
||||
{
|
||||
teamId: collection.teamId,
|
||||
datasetId: collection.datasetId,
|
||||
parentId
|
||||
},
|
||||
'_id',
|
||||
{ session }
|
||||
);
|
||||
|
||||
const idList = children.map((item) => String(item._id));
|
||||
|
||||
const IdChildren = (await Promise.all(idList.map(find))).flat();
|
||||
|
||||
return [...idList, ...IdChildren];
|
||||
};
|
||||
|
||||
const allChildrenIdList = await find(collection._id);
|
||||
|
||||
await MongoDatasetCollection.updateMany(
|
||||
{
|
||||
_id: { $in: allChildrenIdList }
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
forbid
|
||||
}
|
||||
},
|
||||
{
|
||||
session
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
async function handler(req: ApiRequestProps<UpdateDatasetCollectionParams>) {
|
||||
const { id, parentId, name, tags, forbid } = req.body;
|
||||
|
||||
@@ -22,7 +72,7 @@ async function handler(req: ApiRequestProps<UpdateDatasetCollectionParams>) {
|
||||
}
|
||||
|
||||
// 凭证校验
|
||||
await authDatasetCollection({
|
||||
const { collection } = await authDatasetCollection({
|
||||
req,
|
||||
authToken: true,
|
||||
authApiKey: true,
|
||||
@@ -30,15 +80,32 @@ async function handler(req: ApiRequestProps<UpdateDatasetCollectionParams>) {
|
||||
per: WritePermissionVal
|
||||
});
|
||||
|
||||
const updateFields: Record<string, any> = {
|
||||
...(parentId !== undefined && { parentId: parentId || null }),
|
||||
...(name && { name, updateTime: getCollectionUpdateTime({ name }) }),
|
||||
...(tags && { tags }),
|
||||
...(forbid !== undefined && { forbid })
|
||||
};
|
||||
await mongoSessionRun(async (session) => {
|
||||
await MongoDatasetCollection.updateOne(
|
||||
{
|
||||
_id: id
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
...(parentId !== undefined && { parentId: parentId || null }),
|
||||
...(name && { name, updateTime: getCollectionUpdateTime({ name }) }),
|
||||
...(tags && { tags }),
|
||||
...(forbid !== undefined && { forbid })
|
||||
}
|
||||
},
|
||||
{
|
||||
session
|
||||
}
|
||||
);
|
||||
|
||||
await MongoDatasetCollection.findByIdAndUpdate(id, {
|
||||
$set: updateFields
|
||||
// Folder update forbid
|
||||
if (collection.type === DatasetCollectionTypeEnum.folder && forbid !== undefined) {
|
||||
await updateFolderChildrenForbid({
|
||||
collection,
|
||||
forbid,
|
||||
session
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -76,7 +76,7 @@ const FeiShuEditModal = ({
|
||||
<Box color="myGray.600">{t('publish:feishu_api')}</Box>
|
||||
{feConfigs?.docUrl && (
|
||||
<Link
|
||||
href={feConfigs.openAPIDocUrl || getDocPath('/docs/use-cases/feishu-bot')}
|
||||
href={feConfigs.openAPIDocUrl || getDocPath('/docs/use-cases/feishu')}
|
||||
target={'_blank'}
|
||||
ml={2}
|
||||
color={'primary.500'}
|
||||
|
@@ -75,7 +75,7 @@ const OffiAccountEditModal = ({
|
||||
</Box>
|
||||
<Flex p={8} minH={['auto', '400px']} flexDirection="column" gap={6}>
|
||||
<Flex alignItems="center">
|
||||
<Box color="myGray.600">{t('publish:official_account.api')}</Box>
|
||||
<Box color="myGray.600">{t('publish:official_account.params')}</Box>
|
||||
{feConfigs?.docUrl && (
|
||||
<Link
|
||||
href={feConfigs.openAPIDocUrl || getDocPath('/docs/use-cases/official_account')}
|
||||
|
@@ -36,8 +36,9 @@ const SelectAiModelRender = ({ item, inputs = [], nodeId }: RenderInputProps) =>
|
||||
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatMaxToken)?.value ?? 2048,
|
||||
temperature:
|
||||
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatTemperature)?.value ?? 1,
|
||||
isResponseAnswerText:
|
||||
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatIsResponseText)?.value ?? true,
|
||||
isResponseAnswerText: inputs.find(
|
||||
(input) => input.key === NodeInputKeyEnum.aiChatIsResponseText
|
||||
)?.value,
|
||||
aiChatVision:
|
||||
inputs.find((input) => input.key === NodeInputKeyEnum.aiChatVision)?.value ?? true
|
||||
}),
|
||||
|
@@ -95,6 +95,10 @@ export async function getServerSideProps(context: any) {
|
||||
const datasetId = context?.query?.datasetId;
|
||||
|
||||
return {
|
||||
props: { currentTab, datasetId, ...(await serviceSideProps(context, ['dataset', 'file'])) }
|
||||
props: {
|
||||
currentTab,
|
||||
datasetId,
|
||||
...(await serviceSideProps(context, ['dataset', 'file', 'user']))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user