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]] [[package]]
name = "mastodon-image-uploader-bot" name = "mastodon-image-uploader-bot"
version = "0.2.1" version = "0.2.2"
dependencies = [ dependencies = [
"async-std", "async-std",
"log", "log",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "mastodon-image-uploader-bot" name = "mastodon-image-uploader-bot"
version = "0.2.1" version = "0.2.2"
edition = "2021" edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # 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::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());