diff --git a/src/main.rs b/src/main.rs index 78293b0..91d73ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,13 +4,18 @@ use mastodon_async::entities::visibility::Visibility; use mastodon_async::helpers::{cli, toml as masto_toml}; use mastodon_async::prelude::*; use reqwest; -use serde::Deserialize; +use serde::{Deserialize, Serialize}; use std::collections::HashSet; use std::io::{Cursor, Write}; use std::process::exit; use std::time::Duration; use toml; +#[derive(Debug, Serialize)] +struct AccountUpdate { + note: String, +} + const CONFIG_FILENAME: &str = "config.toml"; type DynResult = Result>; @@ -186,16 +191,17 @@ async fn update_bio(account: &Mastodon, config: &Config) -> DynResult<()> { let remaining = urls.difference(&posted).count(); let client = reqwest::Client::new(); + let account_update = AccountUpdate { + note: format!("{}\n\n{} new images remaining", config.bot.bio, remaining), + }; + let response = client .patch(&format!( "{}/api/v1/accounts/update_credentials", config.bot.instance )) .bearer_auth(&account.data.token) - .body(format!( - "note={}\n\n{} new images remaining", - config.bot.bio, remaining - )) + .json(&account_update) .send() .await?; log::info!("Bio updated, response status: {}", response.status());