From 78cb306c07599a99bcb717402c0e263d240e369d Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 15 Jul 2020 09:53:52 -0400 Subject: [PATCH] Don't allow community name editing. Fixes #964 (#973) --- docs/src/contributing_websocket_http_api.md | 1 - server/src/api/community.rs | 11 +----- ui/src/components/community-form.tsx | 39 +++++++++++---------- 3 files changed, 21 insertions(+), 30 deletions(-) diff --git a/docs/src/contributing_websocket_http_api.md b/docs/src/contributing_websocket_http_api.md index 6ed25b98..5af89431 100644 --- a/docs/src/contributing_websocket_http_api.md +++ b/docs/src/contributing_websocket_http_api.md @@ -979,7 +979,6 @@ Mods and admins can remove and lock a community, creators can delete it. op: "EditCommunity", data: { edit_id: i32, - name: String, title: String, description: Option, category_id: i32, diff --git a/server/src/api/community.rs b/server/src/api/community.rs index e5063e0f..80d2d125 100644 --- a/server/src/api/community.rs +++ b/server/src/api/community.rs @@ -98,7 +98,6 @@ pub struct AddModToCommunityResponse { #[derive(Serialize, Deserialize)] pub struct EditCommunity { pub edit_id: i32, - name: String, title: String, description: Option, category_id: i32, @@ -333,10 +332,6 @@ impl Perform for Oper { ) -> Result { let data: &EditCommunity = &self.data; - if let Err(slurs) = slur_check(&data.name) { - return Err(APIError::err(&slurs_vec_to_str(slurs)).into()); - } - if let Err(slurs) = slur_check(&data.title) { return Err(APIError::err(&slurs_vec_to_str(slurs)).into()); } @@ -352,10 +347,6 @@ impl Perform for Oper { Err(_e) => return Err(APIError::err("not_logged_in").into()), }; - if !is_valid_community_name(&data.name) { - return Err(APIError::err("invalid_community_name").into()); - } - let user_id = claims.id; // Check for a site ban @@ -388,7 +379,7 @@ impl Perform for Oper { let read_community = blocking(pool, move |conn| Community::read(conn, edit_id)).await??; let community_form = CommunityForm { - name: data.name.to_owned(), + name: read_community.name, title: data.title.to_owned(), description: data.description.to_owned(), category_id: data.category_id.to_owned(), diff --git a/ui/src/components/community-form.tsx b/ui/src/components/community-form.tsx index 95d9c1f7..1a8ac65a 100644 --- a/ui/src/components/community-form.tsx +++ b/ui/src/components/community-form.tsx @@ -128,26 +128,27 @@ export class CommunityForm extends Component< message={i18n.t('block_leaving')} />
-
- -
- + {!this.props.community && ( +
+ +
+ +
-
- + )}