From 7d08317efda96ea2fea37b1281c19b43ff4dec08 Mon Sep 17 00:00:00 2001 From: Alie Date: Fri, 8 Dec 2023 13:29:23 +0100 Subject: [PATCH 01/11] Added some container stuff --- .dockerignore | 32 ++++++++++++++++++++++++++ Dockerfile | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ cron.yaml | 30 +++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 cron.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..3dfba38 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,32 @@ +# Include any files or directories that you don't want to be copied to your +# container here (e.g., local build artifacts, temporary files, etc.). +# +# For more help, visit the .dockerignore file reference guide at +# https://docs.docker.com/engine/reference/builder/#dockerignore-file + +**/.DS_Store +**/.classpath +**/.dockerignore +**/.env +**/.git +**/.gitignore +**/.project +**/.settings +**/.toolstarget +**/.vs +**/.vscode +**/*.*proj.user +**/*.dbmdl +**/*.jfm +**/charts +**/docker-compose* +**/compose* +**/Dockerfile* +**/node_modules +**/npm-debug.log +**/secrets.dev.yaml +**/values.dev.yaml +/bin +/target +LICENSE +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..edbfe77 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,62 @@ +# syntax=docker/dockerfile:1 + +# Comments are provided throughout this file to help you get started. +# If you need more help, visit the Dockerfile reference guide at +# https://docs.docker.com/engine/reference/builder/ + +################################################################################ +# Create a stage for building the application. + +ARG RUST_VERSION=1.71.0 +ARG APP_NAME=mastodon-image-uploader-bot +FROM rust:${RUST_VERSION}-slim-bullseye AS build +ARG APP_NAME +WORKDIR /app + +# Build the application. +# Leverage a cache mount to /usr/local/cargo/registry/ +# for downloaded dependencies and a cache mount to /app/target/ for +# compiled dependencies which will speed up subsequent builds. +# Leverage a bind mount to the src directory to avoid having to copy the +# source code into the container. Once built, copy the executable to an +# output directory before the cache mounted /app/target is unmounted. +RUN --mount=type=bind,source=src,target=src \ + --mount=type=bind,source=Cargo.toml,target=Cargo.toml \ + --mount=type=bind,source=Cargo.lock,target=Cargo.lock \ + --mount=type=cache,target=/app/target/ \ + --mount=type=cache,target=/usr/local/cargo/registry/ \ + < Date: Sun, 21 Jan 2024 17:21:08 +0100 Subject: [PATCH 02/11] changed configuration for future containerization --- .dockerignore | 2 ++ Dockerfile | 2 +- cron.yaml | 10 ++++------ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index 3dfba38..2705e58 100644 --- a/.dockerignore +++ b/.dockerignore @@ -30,3 +30,5 @@ /target LICENSE README.md +config.toml +mastodon-data.toml \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index edbfe77..9acd250 100644 --- a/Dockerfile +++ b/Dockerfile @@ -59,4 +59,4 @@ USER botuser COPY --from=build /bin/bot /bin/ # What the container should run when it is started. -CMD ["/bin/cd", "/bin/bot"] +CMD ["/bin/bot"] diff --git a/cron.yaml b/cron.yaml index 83d82ee..e6c4adc 100644 --- a/cron.yaml +++ b/cron.yaml @@ -11,20 +11,18 @@ spec: containers: - name: bot-job image: git.fai.st/fedi-image-bot/mastodon-image-uploader-bot:latest - # Command to execute your Rust application or script - command: ["/path/to/your/rust/executable"] volumeMounts: - name: config-toml - mountPath: /botuser/ + mountPath: /app/ readOnly: true - name: mastodon-token - mountPath: /botuser/ + mountPath: /app/ readOnly: true restartPolicy: Never volumes: - - name: config-volume + - name: config-toml configMap: - name: my-config + name: bot-config-toml - name: mastodon-token secret: secretName: mastodon-data From 7fa0eeddf1dda44969fe45c8d8973e6830282b78 Mon Sep 17 00:00:00 2001 From: Alie Date: Sun, 21 Jan 2024 17:23:03 +0100 Subject: [PATCH 03/11] changed permision scopes and rebritten some functions to add modulatiry --- config.toml | 5 ++-- src/main.rs | 74 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/config.toml b/config.toml index 956bec4..d444ea1 100644 --- a/config.toml +++ b/config.toml @@ -6,8 +6,9 @@ bio = "Bot who posts images of sleeping girls every 6 hours." [files] urls = "./urls.csv" posted = "./posted.csv" -tempfile = ".tmp" +tempfile = "/tmp/botimage.png" [errors] -out_of_images = "@Sugui@awoo.fai.st @MeDueleLaTeta@awoo.fai.st me quedé sin chicas" +maintainers = "@Sugui@awoo.fai.st @MeDueleLaTeta@awoo.fai.st" +out_of_images = "me quedé sin chicas" retry = 10 \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 91d73ff..85dc04c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -43,6 +43,7 @@ struct Files { #[derive(Deserialize)] struct Errors { + maintainers: String, out_of_images: String, retry: u8, } @@ -55,25 +56,9 @@ async fn main() -> DynResult<()> { .verbosity(4) // Debug .timestamp(stderrlog::Timestamp::Second) .init()?; - let config: Config = match parse_config(CONFIG_FILENAME) { - Ok(config) => config, - Err(err) => { - log::error!("Config file parsing unsuccesful: {}", err); - exit(1); - } - }; - let mastodon = if let Ok(data) = masto_toml::from_file("mastodon-data.toml") { - Mastodon::from(data) - } else { - match register(&config).await { - Ok(account) => account, - Err(err) => { - log::error!("Api registation unsuccesful: {}", err); - exit(1); - } - } - }; + let config: Config = get_config(); + let mastodon = get_account(&config).await; match get_next_url(&config) { Ok(url) => match url { @@ -106,7 +91,16 @@ async fn main() -> DynResult<()> { } None => { let mut retry: u8 = 0; - while let Err(err) = post(&mastodon, &config.errors.out_of_images).await { + while let Err(err) = post( + &mastodon, + &format!( + "{}{}", + &config.errors.maintainers, &config.errors.out_of_images + ), + Visibility::Direct, + ) + .await + { log::warn!("Cannot post, retry: {}, {}", retry, err); async_std::task::sleep(Duration::new(1, 0)).await; retry += 1; @@ -119,7 +113,13 @@ async fn main() -> DynResult<()> { }, Err(err) => { log::error!("Cannot get next image: {}", err); - match post(&mastodon, &err.to_string()).await { + match post( + &mastodon, + &format!("{}{}", &config.errors.maintainers, &err.to_string()), + Visibility::Direct, + ) + .await + { Ok(_) => {} Err(err) => { log::error!("Cannot post error message: {}", err); @@ -131,6 +131,30 @@ async fn main() -> DynResult<()> { Ok(()) } +fn get_config() -> Config { + match parse_config(CONFIG_FILENAME) { + Ok(config) => config, + Err(err) => { + log::error!("Config file parsing unsuccesful: {}", err); + exit(1); + } + } +} + +async fn get_account(config: &Config) -> Mastodon { + if let Ok(data) = masto_toml::from_file("mastodon-data.toml") { + Mastodon::from(data) + } else { + match register(config).await { + Ok(account) => account, + Err(err) => { + log::error!("Api registation unsuccesful: {}", err); + exit(1); + } + } + } +} + /// Parses the given filename to a config struct fn parse_config(filename: &str) -> DynResult { let toml_file = std::fs::read_to_string(filename)?; //.expect("No config file, consider getting the original one and modifing it"); @@ -208,14 +232,14 @@ async fn update_bio(account: &Mastodon, config: &Config) -> DynResult<()> { Ok(()) } -async fn post(account: &Mastodon, msg: &str) -> DynResult<()> { +async fn post(account: &Mastodon, msg: &str, visibility: Visibility) -> DynResult { let status = StatusBuilder::new() - .visibility(Visibility::Direct) + .visibility(visibility) .status(msg) .build()?; //.expect("Error building error status"); - account.new_status(status).await?; //.expect("Error posting error status"); + let post = account.new_status(status).await?; //.expect("Error posting error status"); log::info!("Text status posted: {}", msg); - Ok(()) + Ok(post) } async fn fetch_url(url: &String, file_name: &String) -> DynResult<()> { @@ -229,7 +253,7 @@ async fn fetch_url(url: &String, file_name: &String) -> DynResult<()> { async fn register(config: &Config) -> DynResult { let registration = Registration::new(&config.bot.instance) .client_name(&config.bot.name) - .scopes(Scopes::write_all()) + .scopes(Scopes::all()) .build() .await?; let mastodon = cli::authenticate(registration).await?; From f0159c40c4f376185650bb7fe931aaee47cfe65f Mon Sep 17 00:00:00 2001 From: Alie Date: Sun, 21 Jan 2024 17:23:43 +0100 Subject: [PATCH 04/11] added 2 funcitonal tests --- src/main.rs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/src/main.rs b/src/main.rs index 85dc04c..602b368 100644 --- a/src/main.rs +++ b/src/main.rs @@ -263,3 +263,45 @@ async fn register(config: &Config) -> DynResult { Ok(mastodon) } + +#[cfg(test)] +mod tests { + + use reqwest::StatusCode; + + use super::*; + const TMPTESTDIR: &str = "/tmp/botimage"; + + #[tokio::test] + async fn fetch_url_should_fetch() { + fetch_url( + &"https://2.gravatar.com/avatar/be8eb8426d68e4beb50790647eda6f6b".to_string(), + &TMPTESTDIR.to_string(), + ) + .await + .unwrap(); + std::fs::read(TMPTESTDIR).unwrap(); + } + + #[tokio::test] + async fn post_should_post() { + let client = reqwest::Client::new(); + let config = get_config(); + let account = get_account(&config).await; + let msg = format!("Test!"); + + let status = post(&account, &msg, Visibility::Direct).await.unwrap(); + let response = client + .get(dbg!(format!( + "{}/api/v1/statuses/{}", + &config.bot.instance, + &status.id.to_string() + ))) + .bearer_auth(dbg!(&account.data.token)) + .send() + .await + .unwrap(); + + assert_eq!(response.status(), StatusCode::OK) + } +} From 8002bec7e07d108d634d19816c6d1436227ee0b3 Mon Sep 17 00:00:00 2001 From: Alie Date: Sun, 21 Jan 2024 17:24:10 +0100 Subject: [PATCH 05/11] fmt --- .dockerignore | 2 +- .gitignore | 2 +- Dockerfile | 2 +- config.toml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.dockerignore b/.dockerignore index 2705e58..7fba8f6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -31,4 +31,4 @@ LICENSE README.md config.toml -mastodon-data.toml \ No newline at end of file +mastodon-data.toml diff --git a/.gitignore b/.gitignore index d948472..9ec0dd3 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ mastodon-data.toml *.csv *.tmp *.log -tmp/ \ No newline at end of file +tmp/ diff --git a/Dockerfile b/Dockerfile index 9acd250..b829760 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,7 +15,7 @@ WORKDIR /app # Build the application. # Leverage a cache mount to /usr/local/cargo/registry/ -# for downloaded dependencies and a cache mount to /app/target/ for +# for downloaded dependencies and a cache mount to /app/target/ for # compiled dependencies which will speed up subsequent builds. # Leverage a bind mount to the src directory to avoid having to copy the # source code into the container. Once built, copy the executable to an diff --git a/config.toml b/config.toml index d444ea1..7aeb5f4 100644 --- a/config.toml +++ b/config.toml @@ -11,4 +11,4 @@ tempfile = "/tmp/botimage.png" [errors] maintainers = "@Sugui@awoo.fai.st @MeDueleLaTeta@awoo.fai.st" out_of_images = "me quedé sin chicas" -retry = 10 \ No newline at end of file +retry = 10 From c011b61e2398a78a20fd5c1fcc47c099140c9f1c Mon Sep 17 00:00:00 2001 From: Alie Date: Sun, 21 Jan 2024 17:27:30 +0100 Subject: [PATCH 06/11] fixed functions were messages where not separated by space --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 602b368..e807cf5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,7 +94,7 @@ async fn main() -> DynResult<()> { while let Err(err) = post( &mastodon, &format!( - "{}{}", + "{} {}", &config.errors.maintainers, &config.errors.out_of_images ), Visibility::Direct, @@ -115,7 +115,7 @@ async fn main() -> DynResult<()> { log::error!("Cannot get next image: {}", err); match post( &mastodon, - &format!("{}{}", &config.errors.maintainers, &err.to_string()), + &format!("{} {}", &config.errors.maintainers, &err.to_string()), Visibility::Direct, ) .await From c2d1b9ee370cf4988e1b1589d1d1b9b7d32e2af2 Mon Sep 17 00:00:00 2001 From: Alie Date: Fri, 26 Jan 2024 17:32:25 +0100 Subject: [PATCH 07/11] add test for image posting --- src/main.rs | 48 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index e807cf5..759c032 100644 --- a/src/main.rs +++ b/src/main.rs @@ -64,7 +64,7 @@ async fn main() -> DynResult<()> { Ok(url) => match url { Some(url) => { let mut retry: u8 = 0; - while let Err(err) = post_image(&mastodon, &url, &config).await { + while let Err(err) = post_image(&mastodon, &url, &config, Visibility::Unlisted).await { log::warn!("Cannot post image, retry: {}, {}", retry, err); async_std::task::sleep(Duration::new(1, 0)).await; retry += 1; @@ -188,7 +188,12 @@ fn get_next_url(config: &Config) -> DynResult> { } } -async fn post_image(account: &Mastodon, url: &String, config: &Config) -> DynResult<()> { +async fn post_image( + account: &Mastodon, + url: &String, + config: &Config, + visibility: Visibility, +) -> DynResult { fetch_url(url, &config.files.tempfile).await?; //.expect("Error fetching url"); let attachment = account .media(&config.files.tempfile, Some(url.to_string())) @@ -198,12 +203,12 @@ async fn post_image(account: &Mastodon, url: &String, config: &Config) -> DynRes .await?; //.expect("Attachment processing error"); let status = StatusBuilder::new() .media_ids(&[attachment.id]) - .visibility(Visibility::Unlisted) + .visibility(visibility) .sensitive(true) .build()?; //.expect("Could not build status"); // we should retry - account.new_status(status).await?; //.expect("Error generating status"); // we should retry or delete last url in posted + let status = account.new_status(status).await?; //.expect("Error generating status"); // we should retry or delete last url in posted log::info!("Image status posted: {}", url); - Ok(()) + Ok(status) } async fn update_bio(account: &Mastodon, config: &Config) -> DynResult<()> { @@ -301,6 +306,39 @@ mod tests { .send() .await .unwrap(); + account.delete_status(&status.id).await.unwrap(); + + assert_eq!(response.status(), StatusCode::OK) + } + + #[tokio::test] + async fn post_image_works() { + let client = reqwest::Client::new(); + let config = get_config(); + let account = get_account(&config).await; + + let status = post_image( + &account, + &"https://2.gravatar.com/avatar/be8eb8426d68e4beb50790647eda6f6b".to_string(), + &config, + Visibility::Direct, + ) + .await + .unwrap(); + + let response = account.get_status(&status.id).await.unwrap(); + + + account.delete_status(&status.id).await.unwrap(); + let attachment = &response.media_attachments[0]; + + + let response = client + .get(attachment.url.clone().unwrap()) + .bearer_auth(dbg!(&account.data.token)) + .send() + .await + .unwrap(); assert_eq!(response.status(), StatusCode::OK) } From 0001567b5537e8868ff6d9ee7bc52c7c2cf480c4 Mon Sep 17 00:00:00 2001 From: Alie Date: Fri, 26 Jan 2024 17:43:46 +0100 Subject: [PATCH 08/11] Refactor code and moved functionality to a funtion --- src/main.rs | 47 +++++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/src/main.rs b/src/main.rs index 759c032..35015c9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use async_std; -use log; +use log::{self, info}; use mastodon_async::entities::visibility::Visibility; use mastodon_async::helpers::{cli, toml as masto_toml}; use mastodon_async::prelude::*; @@ -71,13 +71,10 @@ async fn main() -> DynResult<()> { if retry >= config.errors.retry { log::error!("Max ammount of retries reached on post_image"); log::info!("Reverting file changes"); - while let Err(err) = pop_last_line_of_file(&config.files.posted) { - log::warn!("Failed to revert, retrying: {}", err); - async_std::task::sleep(Duration::new(1, 0)).await; - } exit(1); } } + set_url_as_posted(&config, &url)?; let mut retry: u8 = 0; while let Err(err) = update_bio(&mastodon, &config).await { log::warn!("Cannot update bio, retry: {}, {}", retry, err); @@ -161,15 +158,6 @@ fn parse_config(filename: &str) -> DynResult { Ok(toml::from_str(&toml_file)?) //("Malformed config file, check the original one for reference") } -fn pop_last_line_of_file(filename: &str) -> DynResult<()> { - let binding = std::fs::read_to_string(filename)?; - let mut posted: Vec<_> = binding.lines().collect(); - posted.pop(); - std::fs::write(filename, posted.concat())?; - log::info!("Success reverting changes"); - Ok(()) -} - fn get_next_url(config: &Config) -> DynResult> { let binding = std::fs::read_to_string(&config.files.posted)?; //.expect("Posted file not found"); let posted = binding.lines().collect::>(); @@ -179,15 +167,20 @@ fn get_next_url(config: &Config) -> DynResult> { if urls.is_empty() { Ok(None) } else { - let mut file = std::fs::OpenOptions::new() - .write(true) - .append(true) // This is needed to append to file - .open(&config.files.posted)?; //.expect("Cannot open posted file"); // Maybe we should retry just in case - write!(file, "{}\n", urls[0])?; //.expect("Cannot write to posted file"); // maybe we should retry tbh Ok(Some(urls[0].to_string().clone())) } } +fn set_url_as_posted(config: &Config, url: &String) -> DynResult<()> { + let mut file = std::fs::OpenOptions::new() + .write(true) + .append(true) // This is needed to append to file + .open(&config.files.posted)?; //.expect("Cannot open posted file"); // Maybe we should retry just in case + write!(file, "{}\n", url)?; //.expect("Cannot write to posted file"); // maybe we should retry tbh + info!("Set url {} as posted", url); + Ok(()) +} + async fn post_image( account: &Mastodon, url: &String, @@ -328,17 +321,15 @@ mod tests { let response = account.get_status(&status.id).await.unwrap(); - account.delete_status(&status.id).await.unwrap(); - let attachment = &response.media_attachments[0]; + let attachment = &response.media_attachments[0]; - - let response = client - .get(attachment.url.clone().unwrap()) - .bearer_auth(dbg!(&account.data.token)) - .send() - .await - .unwrap(); + let response = client + .get(attachment.url.clone().unwrap()) + .bearer_auth(dbg!(&account.data.token)) + .send() + .await + .unwrap(); assert_eq!(response.status(), StatusCode::OK) } From cc3d55e5b91006ee3520e4ce5b8ed2cbc2ef2f8a Mon Sep 17 00:00:00 2001 From: Alie Date: Fri, 26 Jan 2024 18:41:44 +0100 Subject: [PATCH 09/11] added alias to run tests --- Cargo.toml | 3 +++ src/main.rs | 55 ++++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3c94170..dc378b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,9 @@ name = "mastodon-image-uploader-bot" version = "0.2.2" edition = "2021" +[alias] +test = "cargo test -- --test-threads=1" + # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] diff --git a/src/main.rs b/src/main.rs index 35015c9..2c5c042 100644 --- a/src/main.rs +++ b/src/main.rs @@ -178,7 +178,7 @@ fn set_url_as_posted(config: &Config, url: &String) -> DynResult<()> { .open(&config.files.posted)?; //.expect("Cannot open posted file"); // Maybe we should retry just in case write!(file, "{}\n", url)?; //.expect("Cannot write to posted file"); // maybe we should retry tbh info!("Set url {} as posted", url); - Ok(()) + Ok(()) } async fn post_image( @@ -269,15 +269,13 @@ mod tests { use super::*; const TMPTESTDIR: &str = "/tmp/botimage"; + const TEST_URL: &str = "https://2.gravatar.com/avatar/be8eb8426d68e4beb50790647eda6f6b"; #[tokio::test] async fn fetch_url_should_fetch() { - fetch_url( - &"https://2.gravatar.com/avatar/be8eb8426d68e4beb50790647eda6f6b".to_string(), - &TMPTESTDIR.to_string(), - ) - .await - .unwrap(); + fetch_url(&TEST_URL.to_string(), &TMPTESTDIR.to_string()) + .await + .unwrap(); std::fs::read(TMPTESTDIR).unwrap(); } @@ -310,14 +308,9 @@ mod tests { let config = get_config(); let account = get_account(&config).await; - let status = post_image( - &account, - &"https://2.gravatar.com/avatar/be8eb8426d68e4beb50790647eda6f6b".to_string(), - &config, - Visibility::Direct, - ) - .await - .unwrap(); + let status = post_image(&account, &TEST_URL.to_string(), &config, Visibility::Direct) + .await + .unwrap(); let response = account.get_status(&status.id).await.unwrap(); @@ -333,4 +326,36 @@ mod tests { assert_eq!(response.status(), StatusCode::OK) } + + #[test] + fn set_as_posted_works() { + let config = get_config(); + + std::fs::write(&config.files.posted, "").unwrap(); + + set_url_as_posted(&config, &TEST_URL.to_string()).unwrap(); + let file = std::fs::read_to_string(&config.files.posted).unwrap(); + let url = file.lines().next_back().unwrap(); + assert_eq!(url, TEST_URL) + } + + #[test] + fn get_next_url_works() { + let config = get_config(); + // Reset file + std::fs::write(&config.files.posted, "").unwrap(); + + // Get test url + let url = get_next_url(&config).unwrap().unwrap(); + assert_eq!(url, TEST_URL); + + set_url_as_posted(&config, &TEST_URL.to_string()).unwrap(); + let file = std::fs::read_to_string(&config.files.posted).unwrap(); + let url = file.lines().next_back().unwrap(); + assert_eq!(url, TEST_URL); + + // Test that now it does not get it + let url = get_next_url(&config).unwrap(); + assert_eq!(url, None); + } } From ab4b0823b618018fd3e237b5f3df9853b5e9f773 Mon Sep 17 00:00:00 2001 From: Alie Date: Fri, 26 Jan 2024 18:48:40 +0100 Subject: [PATCH 10/11] changed version and updated deps --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 95cbfe6..d11b776 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -850,7 +850,7 @@ dependencies = [ [[package]] name = "mastodon-image-uploader-bot" -version = "0.2.2" +version = "0.3.0" dependencies = [ "async-std", "log", @@ -859,7 +859,7 @@ dependencies = [ "serde", "stderrlog", "tokio", - "toml 0.7.6", + "toml 0.8.8", ] [[package]] @@ -1287,9 +1287,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +checksum = "eb3622f419d1296904700073ea6cc23ad690adbd66f13ea683df73298736f0c1" dependencies = [ "serde", ] @@ -1620,9 +1620,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.7.6" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c17e963a819c331dcacd7ab957d80bc2b9a9c1e71c804826d2f283dd65306542" +checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" dependencies = [ "serde", "serde_spanned", @@ -1632,18 +1632,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.3" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.19.13" +version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f8751d9c1b03c6500c387e96f81f815a4f8e72d142d2d4a9ffa6fedd51ddee7" +checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" dependencies = [ "indexmap 2.0.0", "serde", diff --git a/Cargo.toml b/Cargo.toml index dc378b7..3addf43 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mastodon-image-uploader-bot" -version = "0.2.2" +version = "0.3.0" edition = "2021" [alias] @@ -12,7 +12,7 @@ test = "cargo test -- --test-threads=1" tokio = { version = "1", features = ["macros", "rt-multi-thread"] } reqwest = "0.11.14" serde = "1.0.171" -toml = "0.7.1" +toml = "0.8.8" log = "0.4.19" stderrlog = "0.5.4" async-std = "1.12.0" From 25c4ba4b9724799dd4347efba3cc324e73a5d660 Mon Sep 17 00:00:00 2001 From: Alie Date: Fri, 26 Jan 2024 18:53:26 +0100 Subject: [PATCH 11/11] using an import incorrectly --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2c5c042..540e562 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ use async_std; -use log::{self, info}; +use log; use mastodon_async::entities::visibility::Visibility; use mastodon_async::helpers::{cli, toml as masto_toml}; use mastodon_async::prelude::*; @@ -177,7 +177,7 @@ fn set_url_as_posted(config: &Config, url: &String) -> DynResult<()> { .append(true) // This is needed to append to file .open(&config.files.posted)?; //.expect("Cannot open posted file"); // Maybe we should retry just in case write!(file, "{}\n", url)?; //.expect("Cannot write to posted file"); // maybe we should retry tbh - info!("Set url {} as posted", url); + log::info!("Set url {} as posted", url); Ok(()) }