feat: threads

This commit is contained in:
VC
2023-11-11 10:25:41 +01:00
parent eba13ba095
commit b9179d8cce
2 changed files with 45 additions and 23 deletions

View File

@@ -44,6 +44,7 @@ pub async fn run(config: &Config) {
// if we wanted to cut toot in half, now would be the right time to do so
// treats media
for media in toot.media_attachments {
let id = match media.r#type {
AttachmentType::Image => {
@@ -77,12 +78,20 @@ pub async fn run(config: &Config) {
medias.push(id);
}
println!("{:?}", medias);
// threads if necessary
let reply_to = toot.in_reply_to_id.and_then(|t| {
read_state(&conn, Some(t.parse::<u64>().unwrap()))
.ok()
.flatten()
.map(|s| s.tweet_id)
});
let tweet_id = post_tweet(&config.twitter, &tweet_content, &medias)
// posts corresponding tweet
let tweet_id = post_tweet(&config.twitter, &tweet_content, &medias, &reply_to)
.await
.unwrap_or_else(|e| panic!("Cannot Tweet {}: {}", toot.id, e));
// writes the current state of the tweet
write_state(
&conn,
TweetToToot {