@ -12,6 +12,8 @@ use lemmy_api_common::{
is_admin ,
is_admin ,
local_site_rate_limit_to_rate_limit_config ,
local_site_rate_limit_to_rate_limit_config ,
local_user_view_from_jwt ,
local_user_view_from_jwt ,
sanitize_html ,
sanitize_html_opt ,
} ,
} ,
} ;
} ;
use lemmy_db_schema ::{
use lemmy_db_schema ::{
@ -59,10 +61,14 @@ impl PerformCrud for CreateSite {
let actor_id : DbUrl = Url ::parse ( & context . settings ( ) . 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 inbox_url = Some ( generate_site_inbox_url ( & actor_id ) ? ) ;
let keypair = generate_actor_keypair ( ) ? ;
let keypair = generate_actor_keypair ( ) ? ;
let name = sanitize_html ( & data . name ) ;
let sidebar = sanitize_html_opt ( & data . sidebar ) ;
let description = sanitize_html_opt ( & data . description ) ;
let site_form = SiteUpdateForm ::builder ( )
let site_form = SiteUpdateForm ::builder ( )
. name ( Some ( data . name . clone ( ) ) )
. name ( Some ( name) )
. sidebar ( diesel_option_overwrite ( & data . sidebar ) )
. sidebar ( diesel_option_overwrite ( sidebar ) )
. description ( diesel_option_overwrite ( & data . description ) )
. description ( diesel_option_overwrite ( description ) )
. icon ( diesel_option_overwrite_to_url ( & data . icon ) ? )
. icon ( diesel_option_overwrite_to_url ( & data . icon ) ? )
. banner ( diesel_option_overwrite_to_url ( & data . banner ) ? )
. banner ( diesel_option_overwrite_to_url ( & data . banner ) ? )
. actor_id ( Some ( actor_id ) )
. actor_id ( Some ( actor_id ) )
@ -76,6 +82,10 @@ impl PerformCrud for CreateSite {
Site ::update ( & mut context . pool ( ) , site_id , & site_form ) . await ? ;
Site ::update ( & mut context . pool ( ) , site_id , & site_form ) . await ? ;
let application_question = sanitize_html_opt ( & data . application_question ) ;
let default_theme = sanitize_html_opt ( & data . default_theme ) ;
let legal_information = sanitize_html_opt ( & data . legal_information ) ;
let local_site_form = LocalSiteUpdateForm ::builder ( )
let local_site_form = LocalSiteUpdateForm ::builder ( )
// Set the site setup to true
// Set the site setup to true
. site_setup ( Some ( true ) )
. site_setup ( Some ( true ) )
@ -84,15 +94,15 @@ impl PerformCrud for CreateSite {
. enable_nsfw ( data . enable_nsfw )
. enable_nsfw ( data . enable_nsfw )
. community_creation_admin_only ( data . community_creation_admin_only )
. community_creation_admin_only ( data . community_creation_admin_only )
. require_email_verification ( data . require_email_verification )
. require_email_verification ( data . require_email_verification )
. application_question ( diesel_option_overwrite ( & data . application_question ) )
. application_question ( diesel_option_overwrite ( application_question ) )
. private_instance ( data . private_instance )
. private_instance ( data . private_instance )
. default_theme ( d ata. d efault_theme. clone ( ) )
. default_theme ( d efault_theme)
. default_post_listing_type ( data . default_post_listing_type )
. default_post_listing_type ( data . default_post_listing_type )
. legal_information ( diesel_option_overwrite ( & data . legal_information ) )
. legal_information ( diesel_option_overwrite ( legal_information ) )
. application_email_admins ( data . application_email_admins )
. application_email_admins ( data . application_email_admins )
. hide_modlog_mod_names ( data . hide_modlog_mod_names )
. hide_modlog_mod_names ( data . hide_modlog_mod_names )
. updated ( Some ( Some ( naive_now ( ) ) ) )
. updated ( Some ( Some ( naive_now ( ) ) ) )
. slur_filter_regex ( diesel_option_overwrite ( & data . slur_filter_regex ) )
. slur_filter_regex ( diesel_option_overwrite ( data . slur_filter_regex . clone ( ) ) )
. actor_name_max_length ( data . actor_name_max_length )
. actor_name_max_length ( data . actor_name_max_length )
. federation_enabled ( data . federation_enabled )
. federation_enabled ( data . federation_enabled )
. captcha_enabled ( data . captcha_enabled )
. captcha_enabled ( data . captcha_enabled )