mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-20 17:11:19 +02:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
13039f5e76 | ||
![]() |
59005e8aee |
2675
Cargo.lock
generated
Normal file
2675
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
14
src/lib.rs
14
src/lib.rs
@@ -334,7 +334,7 @@ pub async fn run(config: Config) {
|
|||||||
let token = get_oauth2_token(&config);
|
let token = get_oauth2_token(&config);
|
||||||
|
|
||||||
// get Mastodon instance
|
// get Mastodon instance
|
||||||
let mastodon = Arc::new(Mutex::new(get_mastodon_token(&config.mastodon)));
|
let mastodon = get_mastodon_token(&config.mastodon);
|
||||||
|
|
||||||
// get user timeline feed (Vec<tweet>)
|
// get user timeline feed (Vec<tweet>)
|
||||||
let mut feed = get_user_timeline(&config, token, last_tweet_id)
|
let mut feed = get_user_timeline(&config, token, last_tweet_id)
|
||||||
@@ -377,23 +377,23 @@ pub async fn run(config: Config) {
|
|||||||
// reupload the attachments if any
|
// reupload the attachments if any
|
||||||
if let Some(m) = &tweet.extended_entities {
|
if let Some(m) = &tweet.extended_entities {
|
||||||
for media in &m.media {
|
for media in &m.media {
|
||||||
let local_tweet_media_path = match get_tweet_media(&media, &config.scootaloo.cache_path) {
|
let local_tweet_media_path = match get_tweet_media(&media, &config.scootaloo.cache_path).await {
|
||||||
Ok(m) => m,
|
Ok(m) => m,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Cannot get tweet media for {}: {}", &media.url, e);
|
error!("Cannot get tweet media for {}: {}", &media.url, e);
|
||||||
continue;
|
continue;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
let mastodon_media_ids = match mastodon.media(Cow::from(String::from(&local_tweet_media_path))) {
|
let mastodon_media_ids = match mastodon.media(Cow::from(String::from(&local_tweet_media_path))) {
|
||||||
Ok(m) => {
|
Ok(m) => {
|
||||||
remove_file(&local_tweet_media_path).unwrap_or_else(|e|
|
remove_file(&local_tweet_media_path).await.unwrap_or_else(|e|
|
||||||
println!("Attachment for {} has been upload, but I’m unable to remove the existing file: {}", &local_tweet_media_path, e)
|
warn!("Attachment for {} has been uploaded, but I’m unable to remove the existing file: {}", &local_tweet_media_path, e)
|
||||||
);
|
);
|
||||||
m.id
|
m.id
|
||||||
},
|
},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Cannot attach media {} to Mastodon Instance: {}", &local_tweet_media_path, e);
|
error!("Attachment {} cannot be uploaded to Mastodon Instance: {}", &local_tweet_media_path, e);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -415,7 +415,7 @@ pub async fn run(config: Config) {
|
|||||||
|
|
||||||
// publish status
|
// publish status
|
||||||
// again unwrap is safe here as we are in the main thread
|
// again unwrap is safe here as we are in the main thread
|
||||||
mastodon.lock().unwrap().new_status(status).unwrap();
|
mastodon.new_status(status).unwrap();
|
||||||
// this will panic if it cannot publish the status, which is a good thing, it allows the
|
// this will panic if it cannot publish the status, which is a good thing, it allows the
|
||||||
// last_tweet gathered not to be written
|
// last_tweet gathered not to be written
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user