diff --git a/src/api.rs b/src/api.rs index 3e7c189..b3083ca 100644 --- a/src/api.rs +++ b/src/api.rs @@ -340,13 +340,13 @@ fn auth(request: &mut Request, db: &DB) -> IronResult { let password; { let input = request.get_ref::().unwrap(); - username = match input.find(&["username"]) { + username = match input.find(&["username"]) { Some(¶ms::Value::String(ref username)) => username.clone(), - _ => return Err(Error::from(ErrorKind::MissingUsername).into()), + _ => return Err(Error::from(ErrorKind::MissingUsername).into()), }; - password = match input.find(&["password"]) { + password = match input.find(&["password"]) { Some(¶ms::Value::String(ref password)) => password.clone(), - _ => return Err(Error::from(ErrorKind::MissingPassword).into()), + _ => return Err(Error::from(ErrorKind::MissingPassword).into()), }; } @@ -568,14 +568,14 @@ fn read_playlist(request: &mut Request, db: &DB) -> IronResult { }; let params = request.extensions.get::().unwrap(); - let ref playlist_name = match params.find("playlist_name") { + let ref playlist_name = match params.find("playlist_name") { Some(s) => s, - _ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()), + _ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()), }; let playlist_name = match percent_decode(playlist_name.as_bytes()).decode_utf8() { Ok(s) => s, - Err(e) => return Err(Error::from(ErrorKind::EncodingError).into()), + Err(_) => return Err(Error::from(ErrorKind::EncodingError).into()), }; let songs = playlist::read_playlist(&playlist_name, &username, db)?; @@ -595,14 +595,14 @@ fn delete_playlist(request: &mut Request, db: &DB) -> IronResult { }; let params = request.extensions.get::().unwrap(); - let ref playlist_name = match params.find("playlist_name") { + let ref playlist_name = match params.find("playlist_name") { Some(s) => s, - _ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()), + _ => return Err(Error::from(ErrorKind::MissingPlaylistName).into()), }; let playlist_name = match percent_decode(playlist_name.as_bytes()).decode_utf8() { Ok(s) => s, - Err(e) => return Err(Error::from(ErrorKind::EncodingError).into()), + Err(_) => return Err(Error::from(ErrorKind::EncodingError).into()), }; playlist::delete_playlist(&playlist_name, &username, db)?; diff --git a/src/playlist.rs b/src/playlist.rs index 2197c7d..5b47c6a 100644 --- a/src/playlist.rs +++ b/src/playlist.rs @@ -31,7 +31,6 @@ pub struct User { pub struct Playlist { id: i32, owner: i32, - name: String, } #[derive(Identifiable, Queryable, Associations)] @@ -39,8 +38,6 @@ pub struct Playlist { pub struct PlaylistSong { id: i32, playlist: i32, - path: String, - ordering: i32, } #[derive(Insertable)] @@ -111,6 +108,7 @@ pub fn save_playlist(playlist_name: &str, { use self::playlists::dsl::*; playlist = playlists + .select((id, owner)) .filter(name.eq(playlist_name).and(owner.eq(user.id))) .get_result(connection.deref())?; } @@ -176,6 +174,7 @@ pub fn read_playlist(playlist_name: &str, owner: &str, db: &T) -> Result