fix
This commit is contained in:
parent
ca45a6df02
commit
e5a2dfaade
2 changed files with 9 additions and 5 deletions
|
@ -5,7 +5,9 @@ use crate::{get_pg, library::user::User};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
#[derive(Debug, Clone, Serialize, Deserialize, FromRow)]
|
||||||
pub struct Playlist {
|
pub struct Playlist {
|
||||||
pub id: String,
|
pub id: uuid::Uuid,
|
||||||
|
#[sqlx(default)]
|
||||||
|
pub id_str: Option<String>,
|
||||||
pub owner: String,
|
pub owner: String,
|
||||||
pub title: String,
|
pub title: String,
|
||||||
pub visibility: Visibility,
|
pub visibility: Visibility,
|
||||||
|
@ -62,7 +64,7 @@ impl Playlist {
|
||||||
impl Playlist {
|
impl Playlist {
|
||||||
pub async fn api(&self) -> serde_json::Value {
|
pub async fn api(&self) -> serde_json::Value {
|
||||||
serde_json::json!({
|
serde_json::json!({
|
||||||
"id": self.id,
|
"id": if let Some(id) = &self.id_str { id.clone() } else { self.id.to_string() },
|
||||||
"owner": self.owner,
|
"owner": self.owner,
|
||||||
"visibility": serde_json::to_value(&self.visibility).unwrap(),
|
"visibility": serde_json::to_value(&self.visibility).unwrap(),
|
||||||
"title": self.title,
|
"title": self.title,
|
||||||
|
|
|
@ -42,7 +42,8 @@ pub async fn recently_added_playlist() -> FallibleApiResponse {
|
||||||
pub async fn playlist_route(id: &str, u: User) -> FallibleApiResponse {
|
pub async fn playlist_route(id: &str, u: User) -> FallibleApiResponse {
|
||||||
if id == "recents" {
|
if id == "recents" {
|
||||||
return Ok(Playlist {
|
return Ok(Playlist {
|
||||||
id: "recents".to_string(),
|
id: uuid::Uuid::nil(),
|
||||||
|
id_str: Some("recents".to_string()),
|
||||||
owner: u.username,
|
owner: u.username,
|
||||||
title: "Recently Played".to_string(),
|
title: "Recently Played".to_string(),
|
||||||
visibility: Visibility::Public,
|
visibility: Visibility::Public,
|
||||||
|
@ -54,7 +55,8 @@ pub async fn playlist_route(id: &str, u: User) -> FallibleApiResponse {
|
||||||
|
|
||||||
if id == "recentlyAdded" {
|
if id == "recentlyAdded" {
|
||||||
return Ok(Playlist {
|
return Ok(Playlist {
|
||||||
id: "recentlyAdded".to_string(),
|
id: uuid::Uuid::nil(),
|
||||||
|
id_str: Some("recentlyAdded".to_string()),
|
||||||
owner: u.username,
|
owner: u.username,
|
||||||
title: "Recently Added".to_string(),
|
title: "Recently Added".to_string(),
|
||||||
visibility: Visibility::Public,
|
visibility: Visibility::Public,
|
||||||
|
@ -170,7 +172,7 @@ pub async fn playlist_edit_route(
|
||||||
.bind(new_title)
|
.bind(new_title)
|
||||||
.bind(new_vis)
|
.bind(new_vis)
|
||||||
.bind(tracks_ref)
|
.bind(tracks_ref)
|
||||||
.bind(&to_uuid(&playlist_id)?)
|
.bind(&playlist_id)
|
||||||
.fetch_one(get_pg!())
|
.fetch_one(get_pg!())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Reference in a new issue