From fd9cc31848a2d946e84d2de803798f0f1bce0ee0 Mon Sep 17 00:00:00 2001 From: VC Date: Sat, 24 Apr 2021 08:04:52 +0000 Subject: [PATCH] Update src/lib.rs --- src/lib.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index df88ce3..18e2acb 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,7 +6,6 @@ use std::{ fmt, fs::{read_to_string, write}, error::Error, - sync::{Arc, Mutex}, }; // toml @@ -356,7 +355,6 @@ pub async fn run(config: Config) { for tweet in &feed { debug!("Treating Tweet {} inside feed", tweet.id); // determine if the tweet is part of a thread (response to self) or a standard response - debug!("Treating Tweet {} inside feed", tweet.id); if let Some(r) = &tweet.in_reply_to_screen_name { if &r.to_lowercase() != &config.twitter.username.to_lowercase() { // we are responding not threading @@ -376,32 +374,32 @@ pub async fn run(config: Config) { let mut status_medias: Vec = vec![]; - // reupload the attachments if any + // reupload the attachments if any if let Some(m) = &tweet.extended_entities { - let (tx, mut rx) = mpsc::channel(4); - for media in &m.media { - let local_tweet_media_path = match get_tweet_media(&media, &config.scootaloo.cache_path).await { + let local_tweet_media_path = match get_tweet_media(&media, &config.scootaloo.cache_path) { Ok(m) => m, Err(e) => { - warn!("Cannot get tweet media for {}: {}", &media.url, e); + println!("Cannot get tweet media for {}: {}", &media.url, e); continue; }, }; let mastodon_media_ids = match mastodon.media(Cow::from(String::from(&local_tweet_media_path))) { Ok(m) => { - remove_file(&local_tweet_media_path).await.unwrap_or_else(|e| - warn!("Attachment {} has been uploaded but I’m unable to remove the existing file: {}", &local_tweet_media_path, e) + remove_file(&local_tweet_media_path).unwrap_or_else(|e| + println!("Attachment for {} has been upload, but I’m unable to remove the existing file: {}", &local_tweet_media_path, e) ); m.id }, Err(e) => { - error!("Attachment {} cannot be uploaded to Mastodon Instance: {}", &local_tweet_media_path, e); + println!("Cannot attach media {} to Mastodon Instance: {}", &local_tweet_media_path, e); continue; } }; + status_medias.push(mastodon_media_ids); + // last step, removing the reference to the media from with the toot’s text status_text = status_text.replace(&media.url, ""); }