I broke something and then I fixed it but not sure whatI did so...here ya go
This commit is contained in:
parent
dbe75da579
commit
003ca8eb6b
|
@ -45,7 +45,9 @@ impl MastodonClient {
|
||||||
let response = req.send().await?;
|
let response = req.send().await?;
|
||||||
|
|
||||||
if !response.status().is_success() {
|
if !response.status().is_success() {
|
||||||
return Err(anyhow!("API request failed: {}", response.status()));
|
let status = response.status();
|
||||||
|
let body = response.text().await.unwrap_or_else(|_| "Failed to read response body".to_string());
|
||||||
|
return Err(anyhow!("API request failed: {} - {}", status, body));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(response)
|
Ok(response)
|
||||||
|
@ -173,7 +175,10 @@ impl MastodonClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = self.get(&endpoint).await?;
|
let response = self.get(&endpoint).await?;
|
||||||
let statuses: Vec<Status> = response.json().await?;
|
let response_text = response.text().await?;
|
||||||
|
|
||||||
|
let statuses: Vec<Status> = serde_json::from_str(&response_text)
|
||||||
|
.map_err(|e| anyhow!("Failed to parse home timeline JSON: {} - Response: {}", e, &response_text[..std::cmp::min(500, response_text.len())]))?;
|
||||||
Ok(statuses)
|
Ok(statuses)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +200,10 @@ impl MastodonClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = self.get(&endpoint).await?;
|
let response = self.get(&endpoint).await?;
|
||||||
let statuses: Vec<Status> = response.json().await?;
|
let response_text = response.text().await?;
|
||||||
|
|
||||||
|
let statuses: Vec<Status> = serde_json::from_str(&response_text)
|
||||||
|
.map_err(|e| anyhow!("Failed to parse public timeline JSON: {} - Response: {}", e, &response_text[..std::cmp::min(500, response_text.len())]))?;
|
||||||
Ok(statuses)
|
Ok(statuses)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,12 @@ pub struct Account {
|
||||||
pub username: String,
|
pub username: String,
|
||||||
pub acct: String,
|
pub acct: String,
|
||||||
pub display_name: String,
|
pub display_name: String,
|
||||||
|
#[serde(default)]
|
||||||
pub locked: bool,
|
pub locked: bool,
|
||||||
|
#[serde(default)]
|
||||||
pub bot: bool,
|
pub bot: bool,
|
||||||
pub discoverable: Option<bool>,
|
pub discoverable: Option<bool>,
|
||||||
|
#[serde(default)]
|
||||||
pub group: bool,
|
pub group: bool,
|
||||||
pub created_at: DateTime<Utc>,
|
pub created_at: DateTime<Utc>,
|
||||||
pub note: String,
|
pub note: String,
|
||||||
|
@ -18,8 +21,11 @@ pub struct Account {
|
||||||
pub avatar_static: String,
|
pub avatar_static: String,
|
||||||
pub header: String,
|
pub header: String,
|
||||||
pub header_static: String,
|
pub header_static: String,
|
||||||
|
#[serde(default)]
|
||||||
pub followers_count: u64,
|
pub followers_count: u64,
|
||||||
|
#[serde(default)]
|
||||||
pub following_count: u64,
|
pub following_count: u64,
|
||||||
|
#[serde(default)]
|
||||||
pub statuses_count: u64,
|
pub statuses_count: u64,
|
||||||
pub last_status_at: Option<String>,
|
pub last_status_at: Option<String>,
|
||||||
pub source: Option<AccountSource>,
|
pub source: Option<AccountSource>,
|
||||||
|
@ -50,14 +56,19 @@ pub struct Status {
|
||||||
pub created_at: DateTime<Utc>,
|
pub created_at: DateTime<Utc>,
|
||||||
pub in_reply_to_id: Option<String>,
|
pub in_reply_to_id: Option<String>,
|
||||||
pub in_reply_to_account_id: Option<String>,
|
pub in_reply_to_account_id: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
pub sensitive: bool,
|
pub sensitive: bool,
|
||||||
|
#[serde(default)]
|
||||||
pub spoiler_text: String,
|
pub spoiler_text: String,
|
||||||
pub visibility: Visibility,
|
pub visibility: Visibility,
|
||||||
pub language: Option<String>,
|
pub language: Option<String>,
|
||||||
pub uri: String,
|
pub uri: String,
|
||||||
pub url: Option<String>,
|
pub url: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
pub replies_count: u64,
|
pub replies_count: u64,
|
||||||
|
#[serde(default)]
|
||||||
pub reblogs_count: u64,
|
pub reblogs_count: u64,
|
||||||
|
#[serde(default)]
|
||||||
pub favourites_count: u64,
|
pub favourites_count: u64,
|
||||||
pub edited_at: Option<DateTime<Utc>>,
|
pub edited_at: Option<DateTime<Utc>>,
|
||||||
pub favourited: Option<bool>,
|
pub favourited: Option<bool>,
|
||||||
|
|
Loading…
Reference in New Issue