diff options
author | Vika <vika@fireburn.ru> | 2021-09-28 01:57:16 +0300 |
---|---|---|
committer | Vika <vika@fireburn.ru> | 2021-09-28 01:57:16 +0300 |
commit | 5545edcca7d8d67ef156c924351fd9cb912c160b (patch) | |
tree | 8b00b6df6a03530b9898913ede6636284d3f3dcd /src | |
parent | a8a38e54cd6d7c771c1ceecd4d8fcd86c33d3f1e (diff) | |
download | kittybox-5545edcca7d8d67ef156c924351fd9cb912c160b.tar.zst |
Modified the module to use BACKEND_URI
Diffstat (limited to 'src')
-rw-r--r-- | src/database/file/mod.rs | 2 | ||||
-rw-r--r-- | src/frontend/mod.rs | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/src/database/file/mod.rs b/src/database/file/mod.rs index acbb44b..f58317e 100644 --- a/src/database/file/mod.rs +++ b/src/database/file/mod.rs @@ -483,8 +483,10 @@ impl Storage for FileStorage { .create(true) .open(&path).await?; let mut lock = get_lockable_file(file).await; + log::debug!("Created a lock. Locking for writing..."); let mut guard = lock.write()?; + log::debug!("Locked. Writing."); let mut content = String::new(); guard.read_to_string(&mut content).await?; let mut settings: HashMap<String, String> = if content.len() == 0 { diff --git a/src/frontend/mod.rs b/src/frontend/mod.rs index 37420ac..890879c 100644 --- a/src/frontend/mod.rs +++ b/src/frontend/mod.rs @@ -120,6 +120,8 @@ struct OnboardingData { pub async fn onboarding_receiver<S: Storage>(mut req: Request<ApplicationState<S>>) -> Result { use serde_json::json; + log::debug!("Entering onboarding receiver..."); + // This cannot error out as the URL must be valid. Or there is something horribly wrong // and we shouldn't serve this request anyway. <dyn AsMut<tide::http::Request>>::as_mut(&mut req) @@ -127,7 +129,9 @@ pub async fn onboarding_receiver<S: Storage>(mut req: Request<ApplicationState<S .set_scheme("https") .unwrap(); + log::debug!("Parsing the body..."); let body = req.body_json::<OnboardingData>().await?; + log::debug!("Body parsed!"); let backend = &req.state().storage; #[cfg(any(not(debug_assertions), test))] @@ -135,6 +139,8 @@ pub async fn onboarding_receiver<S: Storage>(mut req: Request<ApplicationState<S #[cfg(all(debug_assertions, not(test)))] let me = url::Url::parse("https://localhost:8080/").unwrap(); + log::debug!("me value: {:?}", me); + if get_post_from_database(backend, me.as_str(), None, &None) .await .is_ok() @@ -149,6 +155,7 @@ pub async fn onboarding_receiver<S: Storage>(mut req: Request<ApplicationState<S let user = crate::indieauth::User::new(me.as_str(), "https://kittybox.fireburn.ru/", "create"); + log::debug!("Setting the site name to {}", &body.blog_name); backend .set_setting("site_name", user.me.as_str(), &body.blog_name) .await?; @@ -173,9 +180,13 @@ pub async fn onboarding_receiver<S: Storage>(mut req: Request<ApplicationState<S // post function is just to ensure that the posts will be syndicated // and inserted into proper feeds. Here, we don't have a need for this, // since the h-card is DIRECTLY accessible via its own URL. + log::debug!("Saving the h-card..."); backend.put_post(&hcard, me.as_str()).await?; + log::debug!("Creating feeds..."); for feed in body.feeds { + if &feed.name == "" || &feed.slug == "" { continue }; + log::debug!("Creating feed {} with slug {}", &feed.name, &feed.slug); let (_, feed) = crate::micropub::normalize_mf2( json!({ "type": ["h-feed"], @@ -186,7 +197,7 @@ pub async fn onboarding_receiver<S: Storage>(mut req: Request<ApplicationState<S backend.put_post(&feed, me.as_str()).await?; } - + log::debug!("Saving the h-entry..."); // This basically puts the h-entry post through the normal creation process. // We need to insert it into feeds and optionally send a notification to everywhere. req.set_ext(user); |