summaryrefslogtreecommitdiffstats
path: root/server/src/api/community.rs
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-06-23 21:11:38 -0400
committerDessalines <tyhou13@gmx.com>2020-06-23 21:11:38 -0400
commitdc94e58cbf7e7de10d97331a3056380a3416e0b0 (patch)
tree85ed25783b0470ead3012a9718aea50b39c940dd /server/src/api/community.rs
parentfd6a040568239d2e6949394fdc0ce0f7ac70275c (diff)
parent790b944031f9433be765936763d848ffa6e1b496 (diff)
Merge branch 'master' into federation_merge_from_master_2
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()?;