From: Nutomic Date: Tue, 1 Mar 2022 17:01:23 +0000 (+0000) Subject: Dont hardcode site id in Site::update (#2110) X-Git-Url: http://these/git/%22%7Burl%7D/%7B%60%24%7BghostArchiveUrl%7D/%7B%60/feeds/inbox/%24%7BUserService.Instance.auth%7D.xml%60%7D?a=commitdiff_plain;h=fb4c47d602eb01e1b3925408ef97418faeb30196;p=lemmy.git Dont hardcode site id in Site::update (#2110) --- diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index 7696711c..d2e74eb8 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -42,7 +42,7 @@ impl PerformCrud for EditSite { // Make sure user is an admin is_admin(&local_user_view)?; - let found_site = blocking(context.pool(), Site::read_local_site).await??; + let local_site = blocking(context.pool(), Site::read_local_site).await??; let sidebar = diesel_option_overwrite(&data.sidebar); let description = diesel_option_overwrite(&data.description); @@ -55,7 +55,7 @@ impl PerformCrud for EditSite { } let site_form = SiteForm { - name: data.name.to_owned().unwrap_or(found_site.name), + name: data.name.to_owned().unwrap_or(local_site.name), sidebar, description, icon, @@ -74,7 +74,7 @@ impl PerformCrud for EditSite { }; let update_site = blocking(context.pool(), move |conn| { - Site::update(conn, 1, &site_form) + Site::update(conn, local_site.id, &site_form) }) .await? .map_err(LemmyError::from) @@ -85,7 +85,7 @@ impl PerformCrud for EditSite { // will be able to log in. It really only wants this to be a requirement for NEW signups. // So if it was set from false, to true, you need to update all current users columns to be verified. - if !found_site.require_application && update_site.require_application { + if !local_site.require_application && update_site.require_application { blocking(context.pool(), move |conn| { LocalUser::set_all_users_registration_applications_accepted(conn) }) @@ -94,7 +94,7 @@ impl PerformCrud for EditSite { .map_err(|e| e.with_message("couldnt_set_all_registrations_accepted"))?; } - if !found_site.require_email_verification && update_site.require_email_verification { + if !local_site.require_email_verification && update_site.require_email_verification { blocking(context.pool(), move |conn| { LocalUser::set_all_users_email_verified(conn) })