trade: adjust logging for deserializing confirmations (#237)
This commit is contained in:
parent
f8ae7d4e0e
commit
4fed9486de
3 changed files with 15 additions and 9 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -2217,6 +2217,7 @@ dependencies = [
|
||||||
"secrecy",
|
"secrecy",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"serde_path_to_error",
|
||||||
"standback",
|
"standback",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"uuid",
|
"uuid",
|
||||||
|
|
|
@ -34,6 +34,7 @@ protobuf = "3.2.0"
|
||||||
protobuf-json-mapping = "3.2.0"
|
protobuf-json-mapping = "3.2.0"
|
||||||
hmac-sha256 = "1.1.7"
|
hmac-sha256 = "1.1.7"
|
||||||
phonenumber = "0.3"
|
phonenumber = "0.3"
|
||||||
|
serde_path_to_error = "0.1.11"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
anyhow = "^1.0"
|
anyhow = "^1.0"
|
||||||
|
|
|
@ -179,10 +179,10 @@ impl SteamGuardAccount {
|
||||||
|
|
||||||
trace!("{:?}", resp);
|
trace!("{:?}", resp);
|
||||||
let text = resp.text().unwrap();
|
let text = resp.text().unwrap();
|
||||||
trace!("text: {:?}", text);
|
debug!("Confirmations response: {}", text);
|
||||||
trace!("{}", text);
|
|
||||||
|
|
||||||
let body: ConfirmationListResponse = serde_json::from_str(text.as_str())?;
|
let mut deser = serde_json::Deserializer::from_str(text.as_str());
|
||||||
|
let body: ConfirmationListResponse = serde_path_to_error::deserialize(&mut deser)?;
|
||||||
ensure!(body.success);
|
ensure!(body.success);
|
||||||
Ok(body.conf)
|
Ok(body.conf)
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,8 @@ impl SteamGuardAccount {
|
||||||
let raw = resp.text()?;
|
let raw = resp.text()?;
|
||||||
debug!("send_confirmation_ajax() response body: {:?}", &raw);
|
debug!("send_confirmation_ajax() response body: {:?}", &raw);
|
||||||
|
|
||||||
let body: SendConfirmationResponse = serde_json::from_str(raw.as_str())?;
|
let mut deser = serde_json::Deserializer::from_str(raw.as_str());
|
||||||
|
let body: SendConfirmationResponse = serde_path_to_error::deserialize(&mut deser)?;
|
||||||
|
|
||||||
if !body.success {
|
if !body.success {
|
||||||
return Err(anyhow!("Server responded with failure."));
|
return Err(anyhow!("Server responded with failure."));
|
||||||
|
@ -256,16 +257,19 @@ impl SteamGuardAccount {
|
||||||
let time = steamapi::get_server_time()?.server_time();
|
let time = steamapi::get_server_time()?.server_time();
|
||||||
let query_params = self.get_confirmation_query_params("details", time);
|
let query_params = self.get_confirmation_query_params("details", time);
|
||||||
|
|
||||||
let resp: ConfirmationDetailsResponse = client.get(format!("https://steamcommunity.com/mobileconf/details/{}", conf.id).parse::<Url>().unwrap())
|
let resp = client.get(format!("https://steamcommunity.com/mobileconf/details/{}", conf.id).parse::<Url>().unwrap())
|
||||||
.header("X-Requested-With", "com.valvesoftware.android.steam.community")
|
.header("X-Requested-With", "com.valvesoftware.android.steam.community")
|
||||||
.header(USER_AGENT, "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; Google Nexus 4 - 4.1.1 - API 16 - 768x1280 Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30")
|
.header(USER_AGENT, "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; Google Nexus 4 - 4.1.1 - API 16 - 768x1280 Build/JRO03S) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30")
|
||||||
.header(COOKIE, cookies.cookies(&url).unwrap())
|
.header(COOKIE, cookies.cookies(&url).unwrap())
|
||||||
.query(&query_params)
|
.query(&query_params)
|
||||||
.send()?
|
.send()?;
|
||||||
.json()?;
|
|
||||||
|
|
||||||
ensure!(resp.success);
|
let text = resp.text()?;
|
||||||
Ok(resp.html)
|
let mut deser = serde_json::Deserializer::from_str(text.as_str());
|
||||||
|
let body: ConfirmationDetailsResponse = serde_path_to_error::deserialize(&mut deser)?;
|
||||||
|
|
||||||
|
ensure!(body.success);
|
||||||
|
Ok(body.html)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes the mobile authenticator from the steam account. If this operation succeeds, this object can no longer be considered valid.
|
/// Removes the mobile authenticator from the steam account. If this operation succeeds, this object can no longer be considered valid.
|
||||||
|
|
Loading…
Reference in a new issue