Skip to content

Commit 8b1047e

Browse files
FinleyGefishwww-ww
authored andcommitted
chore: upgrade script & get infos avatar (labring#5625)
* fix: get infos * chore: initv4130
1 parent cdd71a6 commit 8b1047e

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

packages/service/support/permission/controller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const getClbsInfo = async ({
179179
isOwner: Boolean(ownerTmbId && clb.tmbId && ownerTmbId === clb.tmbId)
180180
}),
181181
name: info?.name ?? 'Unknown name',
182-
avatar: info?.avatar ?? (clb.orgId ? DEFAULT_ORG_AVATAR : DEFAULT_TEAM_AVATAR)
182+
avatar: info?.avatar || (clb.orgId ? DEFAULT_ORG_AVATAR : DEFAULT_TEAM_AVATAR)
183183
};
184184
});
185185
};

projects/app/src/pages/api/admin/initv4130.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
21
import { NextAPI } from '@/service/middleware/entry';
3-
import { authCert } from '@fastgpt/service/support/permission/auth/common';
4-
import { MongoApp } from '@fastgpt/service/core/app/schema';
5-
import { AppFolderTypeList } from '@fastgpt/global/core/app/constants';
6-
import { syncChildrenPermission } from '@fastgpt/service/support/permission/inheritPermission';
7-
import { mongoSessionRun } from '@fastgpt/service/common/mongo/sessionRun';
82
import { OwnerRoleVal, PerResourceTypeEnum } from '@fastgpt/global/support/permission/constant';
9-
import { getResourceClbs } from '@fastgpt/service/support/permission/controller';
10-
import { addLog } from '@fastgpt/service/common/system/log';
3+
import { MongoApp } from '@fastgpt/service/core/app/schema';
114
import { MongoDataset } from '@fastgpt/service/core/dataset/schema';
12-
import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants';
5+
import { authCert } from '@fastgpt/service/support/permission/auth/common';
136
import { MongoResourcePermission } from '@fastgpt/service/support/permission/schema';
7+
import { MongoTeamMember } from '@fastgpt/service/support/user/team/teamMemberSchema';
8+
import type { ApiRequestProps, ApiResponseType } from '@fastgpt/service/type/next';
149

1510
export type SyncAppChatLogQuery = {};
1611

@@ -31,10 +26,14 @@ async function handler(
3126
await authCert({ req, authRoot: true });
3227

3328
// find all resources
34-
const [apps, datasets] = await Promise.all([MongoApp.find().lean(), MongoDataset.find().lean()]);
29+
const [apps, datasets, tmbs] = await Promise.all([
30+
MongoApp.find({}, '_id teamId tmbId').lean(),
31+
MongoDataset.find({}, '_id teamId tmbId').lean(),
32+
MongoTeamMember.find({ role: 'owner' }, '_id teamId').lean()
33+
]);
3534

36-
await MongoResourcePermission.bulkWrite([
37-
...apps.map((app) => ({
35+
await MongoResourcePermission.bulkWrite(
36+
apps.map((app) => ({
3837
updateOne: {
3938
filter: {
4039
resourceId: app._id,
@@ -47,8 +46,11 @@ async function handler(
4746
},
4847
upsert: true
4948
}
50-
})),
51-
...datasets.map((dataset) => ({
49+
}))
50+
);
51+
52+
await MongoResourcePermission.bulkWrite(
53+
datasets.map((dataset) => ({
5254
updateOne: {
5355
filter: {
5456
resourceId: dataset._id,
@@ -62,10 +64,22 @@ async function handler(
6264
upsert: true
6365
}
6466
}))
65-
]);
67+
);
68+
69+
await MongoResourcePermission.bulkWrite(
70+
tmbs.map((team) => ({
71+
deleteOne: {
72+
filter: {
73+
resourceType: PerResourceTypeEnum.team,
74+
teamId: team.teamId,
75+
tmbId: team._id
76+
}
77+
}
78+
}))
79+
);
6680

6781
return {
68-
message: 'App and Dataset owner collaborator create completed successfully'
82+
message: 'App, Dataset, Team owner collaborator create/delete completed successfully'
6983
};
7084
}
7185

0 commit comments

Comments
 (0)