- let site_form = SiteForm {
- name: data.name.to_owned().unwrap_or(local_site.name),
- sidebar,
- description,
- icon,
- banner,
- updated: Some(naive_now()),
- enable_downvotes: data.enable_downvotes,
- open_registration: data.open_registration,
- 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,
- private_instance: data.private_instance,
- default_theme: data.default_theme.clone(),
- default_post_listing_type: data.default_post_listing_type.clone(),
- legal_information,
- application_email_admins: data.application_email_admins,
- hide_modlog_mod_names: data.hide_modlog_mod_names,
- ..SiteForm::default()
- };
-
- let update_site = blocking(context.pool(), move |conn| {
- Site::update(conn, local_site.id, &site_form)
+ let name = data.name.to_owned();
+ let site_form = SiteUpdateForm::builder()
+ .name(name)
+ .sidebar(diesel_option_overwrite(&data.sidebar))
+ .description(diesel_option_overwrite(&data.description))
+ .icon(diesel_option_overwrite_to_url(&data.icon)?)
+ .banner(diesel_option_overwrite_to_url(&data.banner)?)
+ .updated(Some(Some(naive_now())))
+ .build();
+
+ blocking(context.pool(), move |conn| {
+ Site::update(conn, site_id, &site_form)
+ })
+ .await
+ // Ignore errors for all these, so as to not throw errors if no update occurs
+ // Diesel will throw an error for empty update forms
+ .ok();
+
+ let local_site_form = LocalSiteUpdateForm::builder()
+ .enable_downvotes(data.enable_downvotes)
+ .open_registration(data.open_registration)
+ .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())
+ .default_post_listing_type(data.default_post_listing_type.clone())
+ .legal_information(diesel_option_overwrite(&data.legal_information))
+ .application_email_admins(data.application_email_admins)
+ .hide_modlog_mod_names(data.hide_modlog_mod_names)
+ .updated(Some(Some(naive_now())))
+ .slur_filter_regex(diesel_option_overwrite(&data.slur_filter_regex))
+ .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())
+ .build();
+
+ let update_local_site = blocking(context.pool(), move |conn| {
+ LocalSite::update(conn, &local_site_form)