First functional version

This commit is contained in:
VC
2023-11-08 16:12:41 +01:00
parent b3ba8637f8
commit 46ebbaadd0
3 changed files with 24 additions and 10 deletions

View File

@@ -4,7 +4,7 @@ pub use config::{parse_toml, Config};
mod state;
pub use state::init_db;
#[allow(unused_imports)]
use state::{read_state, write_state};
use state::{read_state, write_state, TweetToToot};
mod mastodon;
use mastodon::get_mastodon_timeline_since;
@@ -38,9 +38,17 @@ pub async fn run(config: &Config) {
};
// if we wanted to cut toot in half, now would be the right time to do so
// treating medias (nothing for now)
let _tweet_id = post_tweet(&config.twitter, &tweet_content, &[])
let tweet_id = post_tweet(&config.twitter, &tweet_content, &[])
.await
.unwrap_or_else(|e| panic!("Cannot Tweet {}: {}", toot.id, e));
return;
write_state(
&conn,
TweetToToot {
tweet_id,
toot_id: toot.id.parse::<u64>().unwrap(),
},
)
.unwrap_or_else(|e| panic!("Cannot store Toot/Tweet ({}/{}): {}", &toot.id, tweet_id, e));
}
}