From 80aaf81352c7289f9779e40f5c2864f340f393f2 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Wed, 26 Jan 2022 15:31:03 -0500 Subject: [PATCH] Fixing private instance check. Fixes #2064 --- crates/api_common/src/lib.rs | 10 +++++++--- crates/apub_lib/src/object_id.rs | 2 +- crates/routes/src/feeds.rs | 6 +----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/api_common/src/lib.rs b/crates/api_common/src/lib.rs index 6dcdb58bd..a83f0071b 100644 --- a/crates/api_common/src/lib.rs +++ b/crates/api_common/src/lib.rs @@ -280,9 +280,13 @@ pub async fn check_private_instance( pool: &DbPool, ) -> Result<(), LemmyError> { if local_user_view.is_none() { - let site = blocking(pool, Site::read_simple).await??; - if site.private_instance { - return Err(LemmyError::from_message("instance_is_private")); + let site = blocking(pool, Site::read_simple).await?; + + // The site might not be set up yet + if let Ok(site) = site { + if site.private_instance { + return Err(LemmyError::from_message("instance_is_private")); + } } } Ok(()) diff --git a/crates/apub_lib/src/object_id.rs b/crates/apub_lib/src/object_id.rs index 5bb862f68..6a75bf29f 100644 --- a/crates/apub_lib/src/object_id.rs +++ b/crates/apub_lib/src/object_id.rs @@ -161,7 +161,7 @@ where #[allow(clippy::to_string_in_display)] fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { // Use to_string here because Url.display is not useful for us - write!(f, "{}", self.0.to_string()) + write!(f, "{}", self.0) } } diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index eaa1041fe..7b668d7eb 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -97,11 +97,7 @@ async fn get_feed_data( let mut channel_builder = ChannelBuilder::default(); channel_builder .namespaces(RSS_NAMESPACE.to_owned()) - .title(&format!( - "{} - {}", - site_view.site.name, - listing_type.to_string() - )) + .title(&format!("{} - {}", site_view.site.name, listing_type)) .link(context.settings().get_protocol_and_hostname()) .items(items);