From 9edafd94b00a73662d51824dbcba0a018e2140cf Mon Sep 17 00:00:00 2001 From: alyx Date: Thu, 10 Aug 2023 20:45:01 -0400 Subject: Create plain theme, do some escaping, fix some busted envvars, document themes. --- src/ctx.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/ctx.rs') diff --git a/src/ctx.rs b/src/ctx.rs index 6beb634..63b54ff 100644 --- a/src/ctx.rs +++ b/src/ctx.rs @@ -1,9 +1,11 @@ use reqwest::StatusCode; use super::deserialize as de; use std::sync::Arc; +use std::collections::BTreeMap; pub mod model { use std::sync::Arc; + use std::collections::BTreeMap; /// The theme representation of a user. #[derive(serde::Serialize, Debug)] @@ -73,14 +75,15 @@ pub mod model { /// Contains text explaining a potential error. Error { error: &'static str }, /// Contains data about a user and what they're listening to. - Data { user: User, scrobble: Scrobble } + Data { user: User, scrobble: Scrobble, query: BTreeMap } } } #[derive(Debug)] pub struct ResponseCtx(pub model::Data, pub StatusCode); -impl From, (StatusCode, &'static str)>> for ResponseCtx { - fn from(v: Result, (StatusCode, &'static str)>) -> ResponseCtx { +impl From<(Result, (StatusCode, &'static str)>, BTreeMap)> for ResponseCtx { + fn from(v: (Result, (StatusCode, &'static str)>, BTreeMap)) -> ResponseCtx { + let (v, q) = v; match v { Ok(a) => { let (user, track) = a.as_ref(); @@ -111,7 +114,8 @@ impl From, (StatusCode, &'static str)>> for Re now_playing: track.attr.nowplaying, url: track.url.clone(), loved: track.loved.unwrap_or(false) - } + }, + query: q }, StatusCode::OK) }, Err((status, error)) => { -- cgit v1.2.3-54-g00ecf