mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-21 17:34:37 +02:00
Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
11b629203b | ||
![]() |
16792e515a | ||
![]() |
d228ceaaf6 | ||
![]() |
bd7d4dbbb5 | ||
![]() |
ff03b32f9d | ||
![]() |
533a40f2c2 | ||
![]() |
c301649d49 |
@@ -1,13 +1,15 @@
|
|||||||
|
---
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
|
|
||||||
rust-latest:
|
rust-latest:
|
||||||
stage: build
|
stage: build
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- target/release/scootaloo
|
- target/release/scootaloo
|
||||||
image: rust:latest
|
image: rust:latest
|
||||||
script:
|
script:
|
||||||
- cargo build --release --verbose
|
- cargo test
|
||||||
- strip target/release/${CI_PROJECT_NAME}
|
- cargo build --release --verbose
|
||||||
|
- strip target/release/${CI_PROJECT_NAME}
|
||||||
|
2898
Cargo.lock
generated
Normal file
2898
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
Cargo.toml
12
Cargo.toml
@@ -1,21 +1,21 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "scootaloo"
|
name = "scootaloo"
|
||||||
version = "0.4.0"
|
version = "0.4.2"
|
||||||
authors = ["VC <veretcle+framagit@mateu.be>"]
|
authors = ["VC <veretcle+framagit@mateu.be>"]
|
||||||
edition = "2018"
|
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
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
toml = "^0.5"
|
toml = "^0.5"
|
||||||
clap = "^2.33"
|
clap = "^2.34"
|
||||||
futures = "^0.3"
|
futures = "^0.3"
|
||||||
egg-mode = { git = "https://github.com/egg-mode-rs/egg-mode", rev = "6b81073eba9c3b123ca0e80bdb5ef61d1758f131" }
|
egg-mode = "^0.16"
|
||||||
tokio = { version = "1", features = ["full"]}
|
tokio = { version = "1", features = ["full"]}
|
||||||
elefren = "^0.20"
|
elefren = "^0.22"
|
||||||
htmlescape = "^0.3"
|
htmlescape = "^0.3"
|
||||||
reqwest = "^0.11"
|
reqwest = "^0.11"
|
||||||
log = "^0.4"
|
log = "^0.4"
|
||||||
simple_logger = "^1.11"
|
simple_logger = "^2.1"
|
||||||
|
|
||||||
|
23
src/lib.rs
23
src/lib.rs
@@ -207,15 +207,6 @@ async fn cache_media(u: &str, t: &str) -> Result<String, Box<dyn Error>> {
|
|||||||
Ok(dest_filepath)
|
Ok(dest_filepath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********
|
|
||||||
* This is the struct that holds the Mastodon Media ID and the Twitter Media URL at the same Time
|
|
||||||
**********/
|
|
||||||
#[derive(Debug)]
|
|
||||||
struct ScootalooSpawnResponse {
|
|
||||||
mastodon_media_id: String,
|
|
||||||
twitter_media_url: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********
|
/**********
|
||||||
* local error handler
|
* local error handler
|
||||||
**********/
|
**********/
|
||||||
@@ -334,7 +325,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 +368,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 +406,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