-use crate::PerformCrud;
+use crate::{site::check_application_question, PerformCrud};
use activitypub_federation::core::signatures::generate_actor_keypair;
use actix_web::web::Data;
use lemmy_api_common::{
+ context::LemmyContext,
site::{CreateSite, SiteResponse},
utils::{
+ generate_site_inbox_url,
get_local_user_view_from_jwt,
is_admin,
+ local_site_rate_limit_to_rate_limit_config,
local_site_to_slur_regex,
site_description_length_check,
},
};
-use lemmy_apub::generate_site_inbox_url;
use lemmy_db_schema::{
newtypes::DbUrl,
source::{
use lemmy_db_views::structs::SiteView;
use lemmy_utils::{
error::LemmyError,
- utils::{check_application_question, check_slurs, check_slurs_opt},
+ utils::{check_slurs, check_slurs_opt},
ConnectionId,
};
-use lemmy_websocket::LemmyContext;
use url::Url;
#[async_trait::async_trait(?Send)]
}
let application_question = diesel_option_overwrite(&data.application_question);
- check_application_question(&application_question, &data.require_application)?;
+ check_application_question(
+ &application_question,
+ data
+ .registration_mode
+ .unwrap_or(local_site.registration_mode),
+ )?;
let actor_id: DbUrl = Url::parse(&context.settings().get_protocol_and_hostname())?.into();
let inbox_url = Some(generate_site_inbox_url(&actor_id)?);
let keypair = generate_actor_keypair()?;
let site_form = SiteUpdateForm::builder()
- .name(Some(data.name.to_owned()))
+ .name(Some(data.name.clone()))
.sidebar(sidebar)
.description(description)
.icon(icon)
// Set the site setup to true
.site_setup(Some(true))
.enable_downvotes(data.enable_downvotes)
- .open_registration(data.open_registration)
+ .registration_mode(data.registration_mode)
.enable_nsfw(data.enable_nsfw)
.community_creation_admin_only(data.community_creation_admin_only)
.require_email_verification(data.require_email_verification)
- .require_application(data.require_application)
.application_question(application_question)
.private_instance(data.private_instance)
.default_theme(data.default_theme.clone())
.actor_name_max_length(data.actor_name_max_length)
.federation_enabled(data.federation_enabled)
.federation_debug(data.federation_debug)
- .federation_strict_allowlist(data.federation_strict_allowlist)
- .federation_http_fetch_retry_limit(data.federation_http_fetch_retry_limit)
.federation_worker_count(data.federation_worker_count)
.captcha_enabled(data.captcha_enabled)
- .captcha_difficulty(data.captcha_difficulty.to_owned())
+ .captcha_difficulty(data.captcha_difficulty.clone())
.build();
LocalSite::update(context.pool(), &local_site_form).await?;
let site_view = SiteView::read_local(context.pool()).await?;
+ let rate_limit_config =
+ local_site_rate_limit_to_rate_limit_config(&site_view.local_site_rate_limit);
+ context
+ .settings_updated_channel()
+ .send(rate_limit_config)
+ .await?;
+
Ok(SiteResponse { site_view })
}
}