From 858c0ddd9cc36af0acc72efb1ff1bdc1d8e28b0a Mon Sep 17 00:00:00 2001 From: Vika Date: Thu, 22 Jun 2023 21:35:22 +0300 Subject: database: use domains instead of authorities as owner key This allows disregarding http/https comparisons and simplifies some database designs. --- kittybox-rs/src/frontend/mod.rs | 10 +++++----- kittybox-rs/src/frontend/onboarding.rs | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'kittybox-rs/src/frontend') diff --git a/kittybox-rs/src/frontend/mod.rs b/kittybox-rs/src/frontend/mod.rs index d677005..ed3932b 100644 --- a/kittybox-rs/src/frontend/mod.rs +++ b/kittybox-rs/src/frontend/mod.rs @@ -132,13 +132,13 @@ pub async fn homepage( // // btw is it more efficient to fetch these in parallel? let (blogname, webring, channels) = tokio::join!( - db.get_setting::(&path) + db.get_setting::(&host) .map(Result::unwrap_or_default), - db.get_setting::(&path) + db.get_setting::(&host) .map(Result::unwrap_or_default), - db.get_channels(&path).map(|i| i.unwrap_or_default()) + db.get_channels(&host).map(|i| i.unwrap_or_default()) ); // Render the homepage ( @@ -176,10 +176,10 @@ pub async fn homepage( error!("Error while fetching h-card and/or h-feed: {}", err); // Return the error let (blogname, channels) = tokio::join!( - db.get_setting::(&path) + db.get_setting::(&host) .map(Result::unwrap_or_default), - db.get_channels(&path).map(|i| i.unwrap_or_default()) + db.get_channels(&host).map(|i| i.unwrap_or_default()) ); ( diff --git a/kittybox-rs/src/frontend/onboarding.rs b/kittybox-rs/src/frontend/onboarding.rs index f797abd..3f73e62 100644 --- a/kittybox-rs/src/frontend/onboarding.rs +++ b/kittybox-rs/src/frontend/onboarding.rs @@ -68,11 +68,18 @@ async fn onboard( )); } - db.set_setting::(user.me.as_str(), data.blog_name.to_owned()) + let user_domain = format!( + "{}{}", + user.me.host_str().unwrap(), + user.me.port() + .map(|port| format!(":{}", port)) + .unwrap_or_default() + ); + db.set_setting::(&user_domain, data.blog_name.to_owned()) .await .map_err(FrontendError::from)?; - db.set_setting::(user.me.as_str(), false) + db.set_setting::(&user_domain, false) .await .map_err(FrontendError::from)?; -- cgit 1.4.1