use crate::PerformCrud;
+use activitypub_federation::core::signatures::generate_actor_keypair;
use actix_web::web::Data;
use lemmy_api_common::{
- blocking,
- check_image_has_local_domain,
- get_local_user_view_from_jwt,
- is_admin,
- site::*,
- site_description_length_check,
+ site::{CreateSite, SiteResponse},
+ utils::{blocking, get_local_user_view_from_jwt, is_admin, site_description_length_check},
};
use lemmy_apub::generate_site_inbox_url;
use lemmy_db_schema::{
- diesel_option_overwrite,
- diesel_option_overwrite_to_url,
- naive_now,
newtypes::DbUrl,
source::site::{Site, SiteForm},
traits::Crud,
+ utils::{diesel_option_overwrite, diesel_option_overwrite_to_url, naive_now},
};
-use lemmy_db_views::site_view::SiteView;
+use lemmy_db_views::structs::SiteView;
use lemmy_utils::{
- apub::generate_actor_keypair,
- settings::structs::Settings,
+ error::LemmyError,
utils::{check_slurs, check_slurs_opt},
ConnectionId,
- LemmyError,
};
use lemmy_websocket::LemmyContext;
use url::Url;
check_slurs(&data.name, &context.settings().slur_regex())?;
check_slurs_opt(&data.description, &context.settings().slur_regex())?;
- check_image_has_local_domain(icon.as_ref().unwrap_or(&None))?;
- check_image_has_local_domain(banner.as_ref().unwrap_or(&None))?;
// Make sure user is an admin
is_admin(&local_user_view)?;
site_description_length_check(desc)?;
}
- let actor_id: DbUrl = Url::parse(&Settings::get().get_protocol_and_hostname())?.into();
+ 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 = SiteForm {
public_key: Some(keypair.public_key),
default_theme: data.default_theme.clone(),
default_post_listing_type: data.default_post_listing_type.clone(),
+ hide_modlog_mod_names: data.hide_modlog_mod_names,
..SiteForm::default()
};
- let create_site = move |conn: &'_ _| Site::create(conn, &site_form);
+ let create_site = move |conn: &mut _| Site::create(conn, &site_form);
blocking(context.pool(), create_site)
.await?
.map_err(|e| LemmyError::from_error_message(e, "site_already_exists"))?;