let site = blocking(context.pool(), move |conn| Site::read(conn, 0)).await??;
if site.community_creation_admin_only && is_admin(&local_user_view).is_err() {
- return Err(ApiError::err("only_admins_can_create_communities").into());
+ return Err(ApiError::err_plain("only_admins_can_create_communities").into());
}
check_slurs(&data.name, &context.settings().slur_regex())?;
check_slurs_opt(&data.description, &context.settings().slur_regex())?;
if !is_valid_actor_name(&data.name, context.settings().actor_name_max_length) {
- return Err(ApiError::err("invalid_community_name").into());
+ return Err(ApiError::err_plain("invalid_community_name").into());
}
// Double check for duplicate community actor_ids
let community_actor_id_wrapped = ObjectId::<Community>::new(community_actor_id.clone());
let community_dupe = community_actor_id_wrapped.dereference_local(context).await;
if community_dupe.is_ok() {
- return Err(ApiError::err("community_already_exists").into());
+ return Err(ApiError::err_plain("community_already_exists").into());
}
// Check to make sure the icon and banners are urls
Community::create(conn, &community_form)
})
.await?
- .map_err(|_| ApiError::err("community_already_exists"))?;
+ .map_err(|e| ApiError::err("community_already_exists", e))?;
// The community creator becomes a moderator
let community_moderator_form = CommunityModeratorForm {
let join = move |conn: &'_ _| CommunityModerator::join(conn, &community_moderator_form);
if blocking(context.pool(), join).await?.is_err() {
- return Err(ApiError::err("community_moderator_already_exists").into());
+ return Err(ApiError::err_plain("community_moderator_already_exists").into());
}
// Follow your own community
let follow = move |conn: &'_ _| CommunityFollower::follow(conn, &community_follower_form);
if blocking(context.pool(), follow).await?.is_err() {
- return Err(ApiError::err("community_follower_already_exists").into());
+ return Err(ApiError::err_plain("community_follower_already_exists").into());
}
let person_id = local_user_view.person.id;