From 83ba4fe37a1184b998be09b9cbe53a22c7ba9e3b Mon Sep 17 00:00:00 2001 From: alyx Date: Mon, 1 Apr 2024 20:27:44 -0400 Subject: Move caching to src/cache/; Finalize API parsing fixes Font and user cache code has been moved to special files, independant from src/config.rs API parsing changes have been properly tested, and last.fm API JSON is now trace-logged for debugging convenience. --- src/ctx.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ctx.rs') diff --git a/src/ctx.rs b/src/ctx.rs index 0b250b1..6e0d806 100644 --- a/src/ctx.rs +++ b/src/ctx.rs @@ -2,8 +2,8 @@ use reqwest::StatusCode; use super::deserialize as de; use std::sync::Arc; use std::collections::BTreeMap; -use super::font::FontQuery; -use super::config::STATE; +use crate::cache::font::FontQuery; +use super::config::CONFIG; pub mod model { use std::sync::Arc; @@ -126,7 +126,7 @@ impl ResponseCtx { }, scrobble: model::Scrobble { name: track.name.clone(), - album: track.album.name.clone(), + album: track.album.title.clone(), artist: model::Artist { name: track.artist.name.clone(), // image_url: track.artist.images.iter().max_by(|a, b| a.size.cmp(&b.size)).map(|a| a.url.clone()).unwrap_or_else(|| "".into()), @@ -138,8 +138,8 @@ impl ResponseCtx { loved: track.loved.unwrap_or(false) }, font: match font_query { - Some(FontQuery { google_font: Some(f), .. }) if STATE.has_google_api_key() => { - let css = match STATE.get_fontinfo(&f.to_string()).await { + Some(FontQuery { google_font: Some(f), .. }) if CONFIG.has_google_api_key() => { + let css = match crate::cache::font::get_fontinfo(&f.to_string()).await { Ok(css) => css, Err((status, error)) => { return ResponseCtx(model::Root::Error {error}, status); } }; -- cgit v1.2.3-54-g00ecf