Link user to queued song (#59)
* Renaming queue_song function * Queued song linked to user * Cleanup and code formatting
This commit was merged in pull request #59.
This commit is contained in:
+33
-4
@@ -84,10 +84,8 @@ impl Upload {
|
||||
println!("Url: {url:?}");
|
||||
|
||||
let mut headers = reqwest::header::HeaderMap::new();
|
||||
headers.insert(
|
||||
reqwest::header::AUTHORIZATION,
|
||||
HeaderValue::from_str(&token.bearer_token()).unwrap(),
|
||||
);
|
||||
let (auth, auth_val) = syncers::common::auth_header(token).await;
|
||||
headers.insert(auth, auth_val);
|
||||
headers.insert("Accept", HeaderValue::from_str("*/*").unwrap());
|
||||
headers.insert("Connection", HeaderValue::from_str("keep-alive").unwrap());
|
||||
headers.insert("Cache-Control", HeaderValue::from_str("no-cache").unwrap());
|
||||
@@ -115,6 +113,37 @@ impl Upload {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn link_user_to_queued_song(
|
||||
&self,
|
||||
token: &icarus_models::token::AccessToken,
|
||||
queued_song_id: &uuid::Uuid,
|
||||
) -> Result<(), reqwest::Error> {
|
||||
let endpoint = String::from("api/v2/song/queue/link");
|
||||
let url = format!("{}/{endpoint}", self.api.url);
|
||||
|
||||
let mut headers = reqwest::header::HeaderMap::new();
|
||||
let (auth, auth_val) = syncers::common::auth_header(token).await;
|
||||
headers.insert(auth, auth_val);
|
||||
|
||||
let client = reqwest::Client::builder().build().unwrap();
|
||||
|
||||
let payload = serde_json::json!({
|
||||
"song_queue_id": queued_song_id,
|
||||
"user_id": token.user_id
|
||||
});
|
||||
|
||||
match client
|
||||
.patch(url)
|
||||
.headers(headers)
|
||||
.json(&payload)
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
fn init_form(
|
||||
&self,
|
||||
song: &icarus_models::song::Song,
|
||||
|
||||
Reference in New Issue
Block a user