fixed error with update bio
This commit is contained in:
parent
28ccd57474
commit
4a84d306a3
16
src/main.rs
16
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::helpers::{cli, toml as masto_toml};
|
||||||
use mastodon_async::prelude::*;
|
use mastodon_async::prelude::*;
|
||||||
use reqwest;
|
use reqwest;
|
||||||
use serde::Deserialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::io::{Cursor, Write};
|
use std::io::{Cursor, Write};
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize)]
|
||||||
|
struct AccountUpdate {
|
||||||
|
note: String,
|
||||||
|
}
|
||||||
|
|
||||||
const CONFIG_FILENAME: &str = "config.toml";
|
const CONFIG_FILENAME: &str = "config.toml";
|
||||||
|
|
||||||
type DynResult<T> = Result<T, Box<dyn std::error::Error>>;
|
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 remaining = urls.difference(&posted).count();
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
|
||||||
|
let account_update = AccountUpdate {
|
||||||
|
note: format!("{}\n\n{} new images remaining", config.bot.bio, remaining),
|
||||||
|
};
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.patch(&format!(
|
.patch(&format!(
|
||||||
"{}/api/v1/accounts/update_credentials",
|
"{}/api/v1/accounts/update_credentials",
|
||||||
config.bot.instance
|
config.bot.instance
|
||||||
))
|
))
|
||||||
.bearer_auth(&account.data.token)
|
.bearer_auth(&account.data.token)
|
||||||
.body(format!(
|
.json(&account_update)
|
||||||
"note={}\n\n{} new images remaining",
|
|
||||||
config.bot.bio, remaining
|
|
||||||
))
|
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
log::info!("Bio updated, response status: {}", response.status());
|
log::info!("Bio updated, response status: {}", response.status());
|
||||||
|
|
Loading…
Reference in New Issue