feat: stub getPodcasts
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Lys 2023-11-28 05:07:20 +02:00
parent fe1279d2af
commit 5dac029b4e
Signed by: lyssieth
GPG key ID: C9CF3D614FAA3940
3 changed files with 45 additions and 0 deletions

View file

@ -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![] })
)
}

View file

@ -24,6 +24,8 @@ mod get_cover_art;
mod get_artists; mod get_artists;
// rest/getArtist // rest/getArtist
mod get_artist; mod get_artist;
// rest/getPodcasts
mod get_podcasts;
// TODO: Fix the `.ping` issue, figure out how to make it work without the duplication. // TODO: Fix the `.ping` issue, figure out how to make it work without the duplication.
pub fn build() -> Box<dyn Endpoint<Output = poem::Response>> { pub fn build() -> Box<dyn Endpoint<Output = poem::Response>> {
@ -57,5 +59,7 @@ pub fn build() -> Box<dyn Endpoint<Output = poem::Response>> {
.at("/getArtists.view", get_artists::get_artists) .at("/getArtists.view", get_artists::get_artists)
.at("/getArtist", get_artist::get_artist) .at("/getArtist", get_artist::get_artist)
.at("/getArtist.view", 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() .boxed()
} }

View file

@ -114,6 +114,15 @@ where
} }
SubResponseType::Artists { artists } => artists.serialize(s), SubResponseType::Artists { artists } => artists.serialize(s),
SubResponseType::Artist { artist } => artist.serialize(s), SubResponseType::Artist { artist } => artist.serialize(s),
SubResponseType::Podcasts { channels } => {
#[derive(Serialize)]
struct Podcasts<'a> {
#[serde(rename = "podcasts")]
channels: &'a Vec<Podcast>,
}
Podcasts { channels }.serialize(s)
}
SubResponseType::Empty => s.serialize_none(), SubResponseType::Empty => s.serialize_none(),
} }
} }
@ -296,8 +305,15 @@ pub enum SubResponseType {
#[serde(flatten)] #[serde(flatten)]
artist: Box<Artist>, artist: Box<Artist>,
}, },
#[serde(rename = "podcasts")]
Podcasts {
#[serde(rename = "podcast")]
channels: Vec<Podcast>,
},
Empty, Empty,
} }
#[derive(Debug, Clone, Serialize)]
pub struct Podcast;
impl SubResponseType { impl SubResponseType {
pub const fn is_empty(&self) -> bool { pub const fn is_empty(&self) -> bool {