Skip to content

Commit

Permalink
feat: add disableCreateConverseFromGroup in group config
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Aug 18, 2023
1 parent 1a8b94e commit b3d80c4
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
2 changes: 2 additions & 0 deletions client/shared/i18n/langs/en-US/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"k10c018fe": "Teamwork",
"k1141d649": "Version update",
"k11cef91e": "There are some problems with the page",
"k123852c": "Group privacy control to prevent malicious harassment of users through groups.",
"k1252f904": "Gateway",
"k131598d0": "A new version is detected, whether to refresh immediately to upgrade to the latest content",
"k13ae6a93": "Copy",
Expand Down Expand Up @@ -294,6 +295,7 @@
"kb6f1c83f": "What do you want to call you?",
"kb76d94e0": "Refresh",
"kb7a57f24": "Plugin Registry Service",
"kb8021af2": "Disable create converse from group",
"kb8185132": "Or",
"kb8ec7062": "Email verification passed",
"kb96b79c5": "Allow management of invitation links",
Expand Down
2 changes: 2 additions & 0 deletions client/shared/i18n/langs/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"k10c018fe": "工作协同",
"k1141d649": "更新版本",
"k11cef91e": "页面出现了一些问题",
"k123852c": "群组隐私控制,防止通过群组恶意骚扰用户。",
"k1252f904": "服务网关",
"k131598d0": "检测到有新版本, 是否立即刷新以升级到最新内容",
"k13ae6a93": "复制",
Expand Down Expand Up @@ -294,6 +295,7 @@
"kb6f1c83f": "想要让大家如何称呼你",
"kb76d94e0": "刷新",
"kb7a57f24": "插件中心服务",
"kb8021af2": "禁止在群组发起私信",
"kb8185132": "",
"kb8ec7062": "邮箱验证通过",
"kb96b79c5": "允许管理邀请链接",
Expand Down
3 changes: 3 additions & 0 deletions client/shared/model/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ export function getGroupConfigWithInfo(
groupInfo: GroupInfo | null | undefined
): {
hideGroupMemberDiscriminator: boolean;
disableCreateConverseFromGroup: boolean;
[key: string]: unknown;
} {
const config = groupInfo?.config ?? {};

return {
...config,
hideGroupMemberDiscriminator: config.hideGroupMemberDiscriminator ?? false,
disableCreateConverseFromGroup:
config.disableCreateConverseFromGroup ?? false,
};
}

Expand Down
21 changes: 21 additions & 0 deletions client/web/src/components/modals/GroupDetail/Config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ export const GroupConfig: React.FC<{
}
/>

{/* 如果开启了 hideGroupMemberDiscriminator 则视为禁止发起私信 */}
<FullModalField
title={t('禁止在群组发起私信')}
tip={t('群组隐私控制,防止通过群组恶意骚扰用户。')}
content={
<Switch
disabled={
loading || config['hideGroupMemberDiscriminator'] === true
}
checked={
(config['hideGroupMemberDiscriminator'] === true ||
config['disableCreateConverseFromGroup']) ??
false
}
onChange={(checked) =>
handleModifyConfig('disableCreateConverseFromGroup', checked)
}
/>
}
/>

<FullModalField
title={t('群组背景')}
tip={t('个性化配置群组背景')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ export const GroupUserPopover: React.FC<{
const userId = userInfo._id;
const userExtra = userInfo.extra ?? {};
const roleNames = getUserRoleNames(userId, groupInfo);
const { hideGroupMemberDiscriminator } = getGroupConfigWithInfo(groupInfo);
const { hideGroupMemberDiscriminator, disableCreateConverseFromGroup } =
getGroupConfigWithInfo(groupInfo);
const pluginUserExtraInfoEl = usePluginUserExtraInfo(userExtra);
const navigate = useNavigate();
const currentUserId = useUserId();

const allowSendMessage =
!hideGroupMemberDiscriminator && currentUserId !== userId;
!hideGroupMemberDiscriminator &&
!disableCreateConverseFromGroup &&
currentUserId !== userId;

const [, handleCreateConverse] = useAsyncRequest(async () => {
const converse = await createDMConverse([userId]);
Expand Down

0 comments on commit b3d80c4

Please sign in to comment.