Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to limit community creation to admins only (fixes #1586) #1587

Merged
merged 2 commits into from
Apr 22, 2021

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Apr 20, 2021

Quite easy to implement, and its something that has been requested a lot. Maybe the variable could have a better name.

crates/api_common/src/site.rs Show resolved Hide resolved
crates/api_common/src/site.rs Show resolved Hide resolved
@@ -43,6 +47,11 @@ impl PerformCrud for CreateCommunity {
let data: &CreateCommunity = &self;
let local_user_view = get_local_user_view_from_jwt(&data.auth, context.pool()).await?;

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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add this to lemmy-translations

Comment on lines 72 to 75
pub open_registration: bool,
pub enable_nsfw: bool,
pub auth: String,
pub community_creation_admin_only: bool,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side point, but since all of these have defaults, I can probably make them optional.

@Nutomic
Copy link
Member Author

Nutomic commented Apr 22, 2021

Updated.

@dessalines dessalines merged commit db1abff into main Apr 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants