refactor: eliminate response tweet earlier

This commit is contained in:
VC
2022-11-18 10:51:04 +01:00
parent fe3745d91f
commit 93a27deae8
2 changed files with 22 additions and 29 deletions

View File

@@ -27,7 +27,7 @@ pub fn get_oauth2_token(config: &TwitterConfig) -> Token {
}
}
/// Gets Twitter user timeline
/// Gets Twitter user timeline, eliminate responses to others and reverse it
pub async fn get_user_timeline(
screen_name: &str,
token: &Token,
@@ -40,7 +40,18 @@ pub async fn get_user_timeline(
.older(lid)
.await?;
Ok(feed.to_vec())
let mut feed: Vec<Tweet> = feed
.iter()
.cloned()
.filter(|t| match &t.in_reply_to_screen_name {
Some(r) => r.to_lowercase() == screen_name.to_lowercase(),
None => true,
})
.collect();
feed.reverse();
Ok(feed)
}
/// Retrieves a single media from a tweet and store it in a temporary file