Cleanup and code formatting
This commit is contained in:
@@ -388,7 +388,7 @@ impl CommitManager {
|
||||
let members = UploadSongMembers {
|
||||
song: s,
|
||||
coverart: cover_art,
|
||||
token: token
|
||||
token: token,
|
||||
};
|
||||
|
||||
match self.upload_song_process(&members).await {
|
||||
@@ -411,12 +411,7 @@ impl CommitManager {
|
||||
}
|
||||
}
|
||||
|
||||
async fn upload_song_process(
|
||||
&self,
|
||||
// token: &icarus_models::token::AccessToken,
|
||||
// song: &icarus_models::song::Song,
|
||||
data: &UploadSongMembers
|
||||
) -> Result<()> {
|
||||
async fn upload_song_process(&self, data: &UploadSongMembers) -> Result<()> {
|
||||
let mut up = syncers::upload::Upload::default();
|
||||
let host = self.ica_action.retrieve_flag_value(&String::from("-h"));
|
||||
up.set_api(&host);
|
||||
@@ -424,19 +419,14 @@ impl CommitManager {
|
||||
let token = &data.token;
|
||||
let song = &data.song;
|
||||
|
||||
let mut queued_song_id = uuid::Uuid::nil();
|
||||
|
||||
println!("Queueing song");
|
||||
|
||||
match up.queue_song(token, song).await {
|
||||
Ok(id) => {
|
||||
println!("Song queued");
|
||||
queued_song_id = id;
|
||||
}
|
||||
let queued_song_id = match up.queue_song(token, song).await {
|
||||
Ok(id) => id,
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err.to_string()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
println!("Queued song Id: {queued_song_id:?}");
|
||||
|
||||
@@ -449,7 +439,6 @@ impl CommitManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,9 @@ fn retrieve_url_with_id(api: &models::api::Api, id: &uuid::Uuid) -> String {
|
||||
url
|
||||
}
|
||||
|
||||
pub async fn auth_header(token: &icarus_models::token::AccessToken) -> (http::HeaderName, http::HeaderValue) {
|
||||
pub async fn auth_header(
|
||||
token: &icarus_models::token::AccessToken,
|
||||
) -> (http::HeaderName, http::HeaderValue) {
|
||||
let auth = reqwest::header::AUTHORIZATION;
|
||||
let auth_value = http::HeaderValue::from_str(&token.bearer_token()).unwrap();
|
||||
|
||||
|
||||
+16
-16
@@ -85,10 +85,7 @@ impl Upload {
|
||||
|
||||
let mut headers = reqwest::header::HeaderMap::new();
|
||||
let (auth, auth_val) = syncers::common::auth_header(token).await;
|
||||
headers.insert(
|
||||
auth,
|
||||
auth_val
|
||||
);
|
||||
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());
|
||||
@@ -116,16 +113,17 @@ impl Upload {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn link_user_to_queued_song(&self, token: &icarus_models::token::AccessToken, queued_song_id: &uuid::Uuid) -> Result<(), reqwest::Error> {
|
||||
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
|
||||
);
|
||||
headers.insert(auth, auth_val);
|
||||
|
||||
let client = reqwest::Client::builder().build().unwrap();
|
||||
|
||||
@@ -134,13 +132,15 @@ impl Upload {
|
||||
"user_id": token.user_id
|
||||
});
|
||||
|
||||
match client.patch(url).headers(headers).json(&payload).send().await {
|
||||
Ok(_) => {
|
||||
Ok(())
|
||||
}
|
||||
Err(err) => {
|
||||
Err(err)
|
||||
}
|
||||
match client
|
||||
.patch(url)
|
||||
.headers(headers)
|
||||
.json(&payload)
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(_) => Ok(()),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user