fixed error with update bio

This commit is contained in:
Alie 2023-07-19 10:57:22 +02:00
parent 28ccd57474
commit 4a84d306a3
1 changed files with 11 additions and 5 deletions

View File

@ -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<T> = Result<T, Box<dyn std::error::Error>>;
@ -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());