mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-20 17:11:19 +02:00
refactor: twitter threading no longer on top
This commit is contained in:
31
src/lib.rs
31
src/lib.rs
@@ -7,9 +7,7 @@ use config::Config;
|
|||||||
|
|
||||||
mod mastodon;
|
mod mastodon;
|
||||||
pub use mastodon::register;
|
pub use mastodon::register;
|
||||||
use mastodon::{
|
use mastodon::*;
|
||||||
associate_urls, decode_urls, get_mastodon_token, replace_alt_services, twitter_mentions,
|
|
||||||
};
|
|
||||||
|
|
||||||
mod twitter;
|
mod twitter;
|
||||||
use twitter::*;
|
use twitter::*;
|
||||||
@@ -94,19 +92,6 @@ pub async fn run(config: Config) {
|
|||||||
for tweet in &feed {
|
for tweet in &feed {
|
||||||
info!("Treating Tweet {} inside feed", tweet.id);
|
info!("Treating Tweet {} inside feed", tweet.id);
|
||||||
|
|
||||||
let lconn = task_conn.lock().await;
|
|
||||||
// initiate the toot_reply_id var and retrieve the corresponding toot_id
|
|
||||||
let toot_reply_id: Option<String> = tweet.in_reply_to_user_id.and_then(|_| {
|
|
||||||
read_state(
|
|
||||||
&lconn,
|
|
||||||
&mastodon_config.twitter_screen_name,
|
|
||||||
tweet.in_reply_to_status_id,
|
|
||||||
)
|
|
||||||
.unwrap_or(None)
|
|
||||||
.map(|s| s.toot_id)
|
|
||||||
});
|
|
||||||
drop(lconn);
|
|
||||||
|
|
||||||
// basic toot text
|
// basic toot text
|
||||||
let mut status_text = tweet.text.clone();
|
let mut status_text = tweet.text.clone();
|
||||||
|
|
||||||
@@ -150,9 +135,17 @@ pub async fn run(config: Config) {
|
|||||||
|
|
||||||
status_builder.status(status_text).media_ids(status_medias);
|
status_builder.status(status_text).media_ids(status_medias);
|
||||||
|
|
||||||
// theard if necessary
|
// thread if necessary
|
||||||
if let Some(i) = toot_reply_id {
|
if tweet.in_reply_to_user_id.is_some() {
|
||||||
status_builder.in_reply_to(&i);
|
let lconn = task_conn.lock().await;
|
||||||
|
if let Ok(Some(r)) = read_state(
|
||||||
|
&lconn,
|
||||||
|
&mastodon_config.twitter_screen_name,
|
||||||
|
tweet.in_reply_to_status_id,
|
||||||
|
) {
|
||||||
|
status_builder.in_reply_to(&r.toot_id);
|
||||||
|
}
|
||||||
|
drop(lconn);
|
||||||
}
|
}
|
||||||
|
|
||||||
// language if any
|
// language if any
|
||||||
|
Reference in New Issue
Block a user