feat: async treatment of all accounts

This commit is contained in:
VC
2022-11-04 10:23:05 +01:00
parent 73244f9ecc
commit df75520175
4 changed files with 148 additions and 126 deletions

View File

@@ -1,4 +1,3 @@
use crate::config::MastodonConfig;
use crate::config::TwitterConfig;
use crate::util::cache_media;
use crate::ScootalooError;
@@ -30,20 +29,15 @@ pub fn get_oauth2_token(config: &TwitterConfig) -> Token {
/// Gets Twitter user timeline
pub async fn get_user_timeline(
config: &MastodonConfig,
screen_name: &str,
token: &Token,
lid: Option<u64>,
) -> Result<Vec<Tweet>, Box<dyn Error>> {
// fix the page size to 200 as it is the maximum Twitter authorizes
let (_, feed) = user_timeline(
UserID::from(config.twitter_screen_name.to_owned()),
true,
false,
token,
)
.with_page_size(200)
.older(lid)
.await?;
let (_, feed) = user_timeline(UserID::from(screen_name.to_owned()), true, false, token)
.with_page_size(20)
.older(lid)
.await?;
Ok(feed.to_vec())
}