Merge branch 'release/v0.2.2'

This commit is contained in:
Alie 2023-07-19 10:59:40 +02:00
commit ba8bd0302a
3 changed files with 13 additions and 7 deletions

2
Cargo.lock generated
View File

@ -850,7 +850,7 @@ dependencies = [
[[package]]
name = "mastodon-image-uploader-bot"
version = "0.2.1"
version = "0.2.2"
dependencies = [
"async-std",
"log",

View File

@ -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

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());