Skip to content

Commit

Permalink
feat(media-annotation): set default value for submission
Browse files Browse the repository at this point in the history
  • Loading branch information
vnghia committed Apr 10, 2024
1 parent 1abb35d commit e844a4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/open_subsonic/media_annotation/scrobble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ add_common_validate!(ScrobbleParams);
add_axum_response!(ScrobbleBody);

async fn scrobble(pool: &DatabasePool, user_id: Uuid, params: &ScrobbleParams) -> Result<()> {
if params.submission {
if params.submission.unwrap_or(true) {
if let Some(ref times) = params.times {
if params.ids.len() != times.len() {
anyhow::bail!(OSError::InvalidParameter(
Expand Down Expand Up @@ -105,7 +105,7 @@ mod tests {
scrobble(
infra.pool(),
user_id,
&ScrobbleParams { ids: vec![song_id], times: None, submission: true },
&ScrobbleParams { ids: vec![song_id], times: None, submission: Some(true) },
)
.await
.unwrap();
Expand Down Expand Up @@ -136,7 +136,7 @@ mod tests {
scrobble(
infra.pool(),
user_id,
&ScrobbleParams { ids: vec![song_id], times: None, submission: true },
&ScrobbleParams { ids: vec![song_id], times: None, submission: Some(true) },
)
.await
.unwrap();
Expand All @@ -148,7 +148,7 @@ mod tests {
scrobble(
infra.pool(),
user_id,
&ScrobbleParams { ids: song_ids.clone(), times: None, submission: true },
&ScrobbleParams { ids: song_ids.clone(), times: None, submission: Some(true) },
)
.await
.unwrap();
Expand Down Expand Up @@ -182,7 +182,7 @@ mod tests {
scrobble(
infra.pool(),
user_id,
&ScrobbleParams { ids: vec![song_id], times: None, submission: true },
&ScrobbleParams { ids: vec![song_id], times: None, submission: Some(true) },
)
.await
.unwrap();
Expand All @@ -199,7 +199,7 @@ mod tests {
.map(|t: &OffsetDateTime| t.unix_timestamp_nanos() / 1000000)
.collect(),
),
submission: true,
submission: Some(true),
},
)
.await
Expand Down
2 changes: 1 addition & 1 deletion types/src/media_annotation/scrobble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub struct ScrobbleParams {
pub ids: Vec<Uuid>,
#[serde(rename = "time")]
pub times: Option<Vec<i128>>,
pub submission: bool,
pub submission: Option<bool>,
}

#[add_subsonic_response]
Expand Down

0 comments on commit e844a4e

Please sign in to comment.