diff --git a/package.json b/package.json
index 74613fd6..318378c3 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "vocechat-web",
- "version": "0.7.30",
+ "version": "0.7.32",
"homepage": "https://voce.chat",
"dependencies": {
"@metamask/onboarding": "^1.0.1",
diff --git a/public/locales/en/chat.json b/public/locales/en/chat.json
index 8ef6d5d0..f1512feb 100644
--- a/public/locales/en/chat.json
+++ b/public/locales/en/chat.json
@@ -63,5 +63,6 @@
"unblock": "Unblock",
"contact_tip": "This user is not in your contact",
"contact_block_tip": "This user has been blocked by you",
- "file_expired": "File Expired"
+ "file_expired": "File Expired",
+ "only_owner_can_send": "only Channel owner can send message!"
}
diff --git a/public/locales/en/setting.json b/public/locales/en/setting.json
index 73242be8..3a61db2a 100644
--- a/public/locales/en/setting.json
+++ b/public/locales/en/setting.json
@@ -36,7 +36,15 @@
"topic_placeholder": "Let everyone know how to use this channel.",
"visibility": "Channel Visibility",
"public": "Public",
- "private": "Private"
+ "private": "Private",
+ "enable": "Enable",
+ "disable": "Disable",
+ "allow": "Allow",
+ "disallow": "Disallow",
+ "add_friend": "Add friend",
+ "dm_to_member": "DM to Member",
+ "show_email": "Show Email",
+ "only_owner": "Only Owner Send Message"
},
"dm": {
"delete": "Delete User",
diff --git a/public/locales/zh/chat.json b/public/locales/zh/chat.json
index 1da77ac7..98cc0afa 100644
--- a/public/locales/zh/chat.json
+++ b/public/locales/zh/chat.json
@@ -9,7 +9,7 @@
"channel_members": "频道成员",
"add_channel_members": "新增成员",
"welcome_channel": "欢迎来到 {{name}} 频道",
- "welcome_desc": "这是频道 #{{name}} 的开始.",
+ "welcome_desc": "这是频道 #{{name}} 的开始。",
"edit_channel": "编辑频道",
"channel_name": "频道名称",
@@ -22,7 +22,7 @@
"invite_title": "邀请朋友加入{{name}}",
"invite_by_email": "邮件邀请",
- "enable_smtp": "首先开启SMTP",
+ "enable_smtp": "首先开启 SMTP",
"send_invite_link": "或者,向朋友发送邀请链接",
"share_invite_link": "分享此链接,邀请朋友加入",
"invite_link_faq": "链接异常?",
@@ -62,5 +62,6 @@
"unblock": "解除屏蔽",
"contact_tip": "该用户不在您的联系人列表中",
"contact_block_tip": "该用户已被你屏蔽",
- "file_expired": "文件已过期"
+ "file_expired": "文件已过期",
+ "only_owner_can_send": "只有频道创建者才能发消息!"
}
diff --git a/public/locales/zh/setting.json b/public/locales/zh/setting.json
index 3f4d1f63..39d28cc1 100644
--- a/public/locales/zh/setting.json
+++ b/public/locales/zh/setting.json
@@ -36,7 +36,15 @@
"topic_placeholder": "让别人知道这个频道是用来做啥的",
"visibility": "可见性",
"public": "公开",
- "private": "私密"
+ "private": "私密",
+ "enable": "开启",
+ "disable": "关闭",
+ "allow": "允许",
+ "disallow": "禁止",
+ "add_friend": "允许加好友",
+ "dm_to_member": "允许私聊",
+ "show_email": "显示邮箱",
+ "only_owner": "仅创建者可发消息"
},
"overview": {
"title_feat": "特性开关",
@@ -50,6 +58,12 @@
"everyone": "每个人",
"invite": "邀请链接"
},
+ "admin_create_group": {
+ "title": "只允许管理员创建频道",
+ "desc": "如果开启,只有管理员才能创建频道",
+ "enable": "开启",
+ "disable": "关闭"
+ },
"guest_mode": {
"title": "访客模式",
"desc": "开启后,访客可以看到公共频道信息流",
diff --git a/src/components/AddEntriesMenu.tsx b/src/components/AddEntriesMenu.tsx
index b3c14f6a..1c6051c4 100644
--- a/src/components/AddEntriesMenu.tsx
+++ b/src/components/AddEntriesMenu.tsx
@@ -16,6 +16,10 @@ import { shallowEqual } from "react-redux";
export default function AddEntriesMenu() {
const { t } = useTranslation();
const isAdmin = useAppSelector((store) => store.authData.user?.is_admin, shallowEqual);
+ const onlyAdminCreateGroup = useAppSelector(
+ (store) => store.server.only_admin_can_create_group,
+ shallowEqual
+ );
const [isPrivate, setIsPrivate] = useState(false);
const [inviteModalVisible, setInviteModalVisible] = useState(false);
const [searchModalVisible, setSearchModalVisible] = useState(false);
@@ -57,6 +61,7 @@ export default function AddEntriesMenu() {
const itemClass =
"rounded flex items-center gap-2 text-sm font-semibold cursor-pointer px-2 py-2.5 md:hover:bg-gray-800/20 md:dark:hover:bg-gray-200/20";
const iconClass = "w-5 h-5 dark:fill-gray-300";
+ const canPrivateGroup = onlyAdminCreateGroup ? isAdmin : true;
return (
<>
@@ -67,10 +72,12 @@ export default function AddEntriesMenu() {
{t("action.new_channel")}
)}
- -
-
- {t("action.new_private_channel")}
-
+ {canPrivateGroup && (
+ -
+
+ {t("action.new_private_channel")}
+
+ )}
-
{t("action.new_msg")}
diff --git a/src/components/Send/index.tsx b/src/components/Send/index.tsx
index d1d0d898..40abf982 100644
--- a/src/components/Send/index.tsx
+++ b/src/components/Send/index.tsx
@@ -40,7 +40,7 @@ const Send: FC = ({
const editorRef = useRef(null);
const { t } = useTranslation("chat");
- const { unblockThisContact, blocked } = useUserOperation({
+ const { unblockThisContact, blocked, isChannelOwner } = useUserOperation({
uid: context == "dm" ? id : undefined,
cid: context == "channel" ? id : undefined
});
@@ -143,6 +143,17 @@ const Send: FC = ({
const members =
context == "channel" ? (channelsData[id]?.is_public ? uids : channelsData[id]?.members) : [];
const isMarkdownMode = mode == Modes.markdown;
+ const onlyOwnerCanSend = !!(context == "channel"
+ ? channelsData[id]?.only_owner_can_send_msg
+ : false);
+ const canSendMessageInChannel = !isChannelOwner && onlyOwnerCanSend;
+ if (canSendMessageInChannel) {
+ return (
+
+ only Channel owner can send message!
+
+ );
+ }
if (context == "dm" && blocked) {
return (
diff --git a/src/hooks/useUserOperation.ts b/src/hooks/useUserOperation.ts
index 2b945c82..1dcbad83 100644
--- a/src/hooks/useUserOperation.ts
+++ b/src/hooks/useUserOperation.ts
@@ -144,7 +144,8 @@ const useUserOperation = ({ uid, cid }: IProps) => {
const canRemoveFromContact: boolean = loginUid != uid;
const canInviteChannel = !!cid && (loginUser?.is_admin || channel?.owner == loginUser?.uid);
return {
- isAdmin: !!user?.is_admin,
+ isChannelOwner: loginUser?.uid == channel?.owner,
+ isAdmin,
updateRole,
canUpdateRole: isAdmin && loginUid != uid && uid != 1,
removeFromContact,
diff --git a/src/routes/settingChannel/Overview/AddFriend.tsx b/src/routes/settingChannel/Overview/AddFriend.tsx
index e1f228ac..420888af 100644
--- a/src/routes/settingChannel/Overview/AddFriend.tsx
+++ b/src/routes/settingChannel/Overview/AddFriend.tsx
@@ -17,7 +17,7 @@ type Props = {
};
const AddFriend = ({ id, add_friend }: Props) => {
- const { t } = useTranslation("setting");
+ const { t } = useTranslation("setting", { keyPrefix: "channel" });
const { t: ct } = useTranslation();
const [refetch] = useLazyGetChannelQuery();
// const onlyAdminCreateGroup = useAppSelector(
@@ -35,9 +35,9 @@ const AddFriend = ({ id, add_friend }: Props) => {
updateSetting({ id, add_friend: newVal });
};
return (
-
+
{
diff --git a/src/routes/settingChannel/Overview/DMMember.tsx b/src/routes/settingChannel/Overview/DMMember.tsx
index 09cc8504..32594e9c 100644
--- a/src/routes/settingChannel/Overview/DMMember.tsx
+++ b/src/routes/settingChannel/Overview/DMMember.tsx
@@ -17,7 +17,7 @@ type Props = {
};
const DMMember = ({ id, dm_to_member }: Props) => {
- const { t } = useTranslation("setting");
+ const { t } = useTranslation("setting", { keyPrefix: "channel" });
const { t: ct } = useTranslation();
const [refetch] = useLazyGetChannelQuery();
// const onlyAdminCreateGroup = useAppSelector(
@@ -35,9 +35,9 @@ const DMMember = ({ id, dm_to_member }: Props) => {
updateSetting({ id, dm_to_member: newVal });
};
return (
-
+
{
diff --git a/src/routes/settingChannel/Overview/OnlyOwnerCanSendMsg.tsx b/src/routes/settingChannel/Overview/OnlyOwnerCanSendMsg.tsx
index 69333fe0..cb0bf6ea 100644
--- a/src/routes/settingChannel/Overview/OnlyOwnerCanSendMsg.tsx
+++ b/src/routes/settingChannel/Overview/OnlyOwnerCanSendMsg.tsx
@@ -17,7 +17,7 @@ type Props = {
};
const OnlyOwnerCanSendMsg = ({ id, only_owner_can_send_msg }: Props) => {
- const { t } = useTranslation("setting");
+ const { t } = useTranslation("setting", { keyPrefix: "channel" });
const { t: ct } = useTranslation();
const [refetch] = useLazyGetChannelQuery();
// const onlyAdminCreateGroup = useAppSelector(
@@ -35,9 +35,9 @@ const OnlyOwnerCanSendMsg = ({ id, only_owner_can_send_msg }: Props) => {
updateSetting({ id, only_owner_can_send_msg: newVal });
};
return (
-
+
{
diff --git a/src/routes/settingChannel/Overview/ShowEmail.tsx b/src/routes/settingChannel/Overview/ShowEmail.tsx
index 4f44bbe9..544c405d 100644
--- a/src/routes/settingChannel/Overview/ShowEmail.tsx
+++ b/src/routes/settingChannel/Overview/ShowEmail.tsx
@@ -17,7 +17,7 @@ type Props = {
};
const ShowEmail = ({ id, show_email }: Props) => {
- const { t } = useTranslation("setting");
+ const { t } = useTranslation("setting", { keyPrefix: "channel" });
const { t: ct } = useTranslation();
const [refetch] = useLazyGetChannelQuery();
// const onlyAdminCreateGroup = useAppSelector(
@@ -35,9 +35,9 @@ const ShowEmail = ({ id, show_email }: Props) => {
updateSetting({ id, show_email: newVal });
};
return (
-
+
{