summaryrefslogtreecommitdiffstats
path: root/server/src/api/community.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/api/community.rs')
-rw-r--r--server/src/api/community.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/server/src/api/community.rs b/server/src/api/community.rs
index cb412fcc..3fc67eb3 100644
--- a/server/src/api/community.rs
+++ b/server/src/api/community.rs
@@ -1,3 +1,4 @@
+use super::*;
use crate::{
api::{APIError, Oper, Perform},
apub::{
@@ -6,19 +7,8 @@ use crate::{
ActorType,
EndpointType,
},
- db::{
- community::*,
- community_view::*,
- moderator::*,
- site::*,
- user::*,
- user_view::*,
- Bannable,
- Crud,
- Followable,
- Joinable,
- SortType,
- },
+ db::{Bannable, Crud, Followable, Joinable, SortType},
+ is_valid_community_name,
naive_from_unix,
naive_now,
slur_check,
@@ -259,6 +249,10 @@ impl Perform for Oper<CreateCommunity> {
}
}
+ if !is_valid_community_name(&data.name) {
+ return Err(APIError::err("invalid_community_name").into());
+ }
+
let user_id = claims.id;
let conn = pool.get()?;
@@ -353,6 +347,10 @@ impl Perform for Oper<EditCommunity> {
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;
let conn = pool.get()?;