diff --git a/rave/src/rest/get_podcasts.rs b/rave/src/rest/get_podcasts.rs new file mode 100644 index 0000000..34f1223 --- /dev/null +++ b/rave/src/rest/get_podcasts.rs @@ -0,0 +1,25 @@ +use crate::{json_or_xml, subsonic::SubResponseType, utils::db::DbTxn}; +use poem::web::Data; +use tracing::instrument; + +use crate::{ + authentication::Authentication, + subsonic::SubsonicResponse, + utils::{self}, +}; + +#[poem::handler] +#[instrument(skip(txn, auth))] +pub async fn get_podcasts(Data(txn): Data<&DbTxn>, auth: Authentication) -> poem::Response { + let u = utils::verify_user(txn.clone(), &auth).await; + + match u { + Ok(_) => {} + Err(e) => return json_or_xml!(auth, e), + }; + + json_or_xml!( + auth, + SubsonicResponse::new(SubResponseType::Podcasts { channels: vec![] }) + ) +} diff --git a/rave/src/rest/mod.rs b/rave/src/rest/mod.rs index 99d0846..d2dc29d 100644 --- a/rave/src/rest/mod.rs +++ b/rave/src/rest/mod.rs @@ -24,6 +24,8 @@ mod get_cover_art; mod get_artists; // rest/getArtist mod get_artist; +// rest/getPodcasts +mod get_podcasts; // TODO: Fix the `.ping` issue, figure out how to make it work without the duplication. pub fn build() -> Box> { @@ -57,5 +59,7 @@ pub fn build() -> Box> { .at("/getArtists.view", get_artists::get_artists) .at("/getArtist", get_artist::get_artist) .at("/getArtist.view", get_artist::get_artist) + .at("/getPodcasts", get_podcasts::get_podcasts) + .at("/getPodcasts.view", get_podcasts::get_podcasts) .boxed() } diff --git a/rave/src/subsonic/mod.rs b/rave/src/subsonic/mod.rs index ee2eb12..36a0d4b 100644 --- a/rave/src/subsonic/mod.rs +++ b/rave/src/subsonic/mod.rs @@ -114,6 +114,15 @@ where } SubResponseType::Artists { artists } => artists.serialize(s), SubResponseType::Artist { artist } => artist.serialize(s), + SubResponseType::Podcasts { channels } => { + #[derive(Serialize)] + struct Podcasts<'a> { + #[serde(rename = "podcasts")] + channels: &'a Vec, + } + + Podcasts { channels }.serialize(s) + } SubResponseType::Empty => s.serialize_none(), } } @@ -296,8 +305,15 @@ pub enum SubResponseType { #[serde(flatten)] artist: Box, }, + #[serde(rename = "podcasts")] + Podcasts { + #[serde(rename = "podcast")] + channels: Vec, + }, Empty, } +#[derive(Debug, Clone, Serialize)] +pub struct Podcast; impl SubResponseType { pub const fn is_empty(&self) -> bool {