diff --git a/client/shared/utils/role-helper.ts b/client/shared/utils/role-helper.ts
index 54caa3b8..15e77331 100644
--- a/client/shared/utils/role-helper.ts
+++ b/client/shared/utils/role-helper.ts
@@ -51,6 +51,7 @@ export const PERMISSION = {
unlimitedInvite: 'core.unlimitedInvite',
editInvite: 'core.editInvite',
groupDetail: 'core.groupDetail',
+ groupBaseInfo: 'core.groupBaseInfo',
groupConfig: 'core.groupConfig',
manageUser: 'core.manageUser',
managePanel: 'core.managePanel',
@@ -101,6 +102,13 @@ export const getPermissionList = (): PermissionItemType[] => [
desc: t('允许成员查看群组详情'),
default: false,
},
+ {
+ key: PERMISSION.core.groupBaseInfo,
+ title: t('修改群组基本信息'),
+ desc: t('允许成员修改群组基本信息'),
+ default: false,
+ required: [PERMISSION.core.groupDetail],
+ },
{
key: PERMISSION.core.groupConfig,
title: t('修改群组配置'),
diff --git a/client/web/src/components/modals/GroupDetail/Summary.tsx b/client/web/src/components/modals/GroupDetail/Summary.tsx
index 7d272de0..02c593d0 100644
--- a/client/web/src/components/modals/GroupDetail/Summary.tsx
+++ b/client/web/src/components/modals/GroupDetail/Summary.tsx
@@ -11,18 +11,23 @@ import React from 'react';
import { Avatar } from 'tailchat-design';
import {
modifyGroupField,
+ PERMISSION,
showSuccessToasts,
showToasts,
t,
UploadFileResult,
useAsyncRequest,
useGroupInfo,
+ useHasGroupPermission,
} from 'tailchat-shared';
export const GroupSummary: React.FC<{
groupId: string;
}> = React.memo(({ groupId }) => {
const groupInfo = useGroupInfo(groupId);
+ const [hasBaseInfoPermission] = useHasGroupPermission(groupId, [
+ PERMISSION.core.groupBaseInfo,
+ ]);
const [, handleUpdateGroupName] = useAsyncRequest(
async (newName: string) => {
@@ -70,7 +75,7 @@ export const GroupSummary: React.FC<{
{groupInfo.description ?? ''}} - editable={true} + editable={hasBaseInfoPermission} renderEditor={GroupDescriptionEditorRender} onSave={handleUpdateGroupDescription} /> diff --git a/server/packages/sdk/src/services/lib/role.ts b/server/packages/sdk/src/services/lib/role.ts index c8e62058..4294f7dd 100644 --- a/server/packages/sdk/src/services/lib/role.ts +++ b/server/packages/sdk/src/services/lib/role.ts @@ -9,6 +9,7 @@ export const PERMISSION = { unlimitedInvite: 'core.unlimitedInvite', editInvite: 'core.editInvite', // 编辑邀请码权限,需要有创建无限制邀请码的权限 groupDetail: 'core.groupDetail', + groupBaseInfo: 'core.groupBaseInfo', groupConfig: 'core.groupConfig', manageUser: 'core.manageUser', managePanel: 'core.managePanel', diff --git a/server/services/core/group/group.service.ts b/server/services/core/group/group.service.ts index 51ba684c..002a5bc6 100644 --- a/server/services/core/group/group.service.ts +++ b/server/services/core/group/group.service.ts @@ -425,19 +425,32 @@ class GroupService extends TcService { throw new EntityError(t('该数据不允许修改')); } - const [isGroupOwner, hasRolePermission] = await call( - ctx - ).checkUserPermissions(groupId, userId, [ + const [ + isGroupOwner, + hasBaseInfoPermission, + hasRolePermission, + hasManagePanelPermission, + ] = await call(ctx).checkUserPermissions(groupId, userId, [ PERMISSION.core.owner, + PERMISSION.core.groupBaseInfo, PERMISSION.core.manageRoles, + PERMISSION.core.managePanel, ]); - if (fieldName === 'fallbackPermissions') { + if (['roles', 'fallbackPermissions'].includes(fieldName)) { if (!hasRolePermission) { - throw new NoPermissionError(t('没有操作权限')); + throw new NoPermissionError(t('没有编辑群组身份组权限')); + } + } else if (['name', 'avatar', 'description'].includes(fieldName)) { + if (!hasBaseInfoPermission) { + throw new NoPermissionError(t('没有编辑群组信息权限')); + } + } else if (fieldName === 'panels') { + if (!hasManagePanelPermission) { + throw new NoPermissionError(t('没有编辑群组面板权限')); } } else if (!isGroupOwner) { - throw new NoPermissionError(t('不是群组管理员无法编辑')); + throw new NoPermissionError(t('不是群组所有者无法编辑')); } const group = await this.adapter.model.findById(groupId).exec();