Playlist DTO
This commit is contained in:
parent
98bcd41e43
commit
765de35f89
3 changed files with 18 additions and 4 deletions
src/server
|
@ -658,8 +658,15 @@ async fn get_playlist(
|
|||
Ok(s) => s,
|
||||
Err(e) => return APIError::from(e).into_response(),
|
||||
};
|
||||
let song_list = make_song_list(playlist.songs, &index_manager).await;
|
||||
song_list_to_response(song_list, api_version)
|
||||
|
||||
match api_version {
|
||||
APIMajorVersion::V7 => Json(playlist.songs).into_response(),
|
||||
APIMajorVersion::V8 => Json(dto::Playlist {
|
||||
header: playlist.header.into(),
|
||||
songs: make_song_list(playlist.songs, &index_manager).await,
|
||||
})
|
||||
.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
async fn delete_playlist(
|
||||
|
|
|
@ -93,6 +93,13 @@ impl From<playlist::PlaylistHeader> for PlaylistHeader {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct Playlist {
|
||||
#[serde(flatten)]
|
||||
pub header: PlaylistHeader,
|
||||
pub songs: SongList,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct SavePlaylistInput {
|
||||
pub tracks: Vec<PathBuf>,
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||
|
||||
use http::StatusCode;
|
||||
|
||||
use crate::server::dto::{self, SongList};
|
||||
use crate::server::dto::{self};
|
||||
use crate::server::test::protocol::{V7, V8};
|
||||
use crate::server::test::{constants::*, protocol, ServiceType, TestService};
|
||||
use crate::test_name;
|
||||
|
@ -85,7 +85,7 @@ async fn get_playlist_golden_path() {
|
|||
}
|
||||
|
||||
let request = protocol::read_playlist::<V8>(TEST_PLAYLIST_NAME);
|
||||
let response = service.fetch_json::<_, SongList>(&request).await;
|
||||
let response = service.fetch_json::<_, dto::Playlist>(&request).await;
|
||||
assert_eq!(response.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue