From 4a84d306a37bf51dfb2a1c84c4921b16e7c29949 Mon Sep 17 00:00:00 2001 From: Alie Date: Wed, 19 Jul 2023 10:57:22 +0200 Subject: [PATCH 1/2] fixed error with update bio --- src/main.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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()); From 0c9e5b4a9eb58e53baef1ac45bab3f9fc10af08f Mon Sep 17 00:00:00 2001 From: Alie Date: Wed, 19 Jul 2023 10:59:35 +0200 Subject: [PATCH 2/2] this is actually a hotfix --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e41e81a..95cbfe6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -850,7 +850,7 @@ dependencies = [ [[package]] name = "mastodon-image-uploader-bot" -version = "0.2.1" +version = "0.2.2" dependencies = [ "async-std", "log", diff --git a/Cargo.toml b/Cargo.toml index a005787..3c94170 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mastodon-image-uploader-bot" -version = "0.2.1" +version = "0.2.2" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html