mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-20 17:11:19 +02:00
feat: add customizable page_size to twitter timeline
This commit is contained in:
16
src/lib.rs
16
src/lib.rs
@@ -28,6 +28,7 @@ use tokio::{spawn, sync::Mutex};
|
||||
use futures::StreamExt;
|
||||
|
||||
const DEFAULT_RATE_LIMIT: usize = 4;
|
||||
const DEFAULT_PAGE_SIZE: i32 = 200;
|
||||
|
||||
/// This is where the magic happens
|
||||
#[tokio::main]
|
||||
@@ -44,6 +45,11 @@ pub async fn run(config: Config) {
|
||||
|
||||
let mut stream = futures::stream::iter(config.mastodon.into_values())
|
||||
.map(|mastodon_config| {
|
||||
// calculate Twitter page size
|
||||
let page_size = mastodon_config
|
||||
.twitter_page_size
|
||||
.unwrap_or_else(|| config.twitter.page_size.unwrap_or(DEFAULT_PAGE_SIZE));
|
||||
|
||||
// create temporary value for each task
|
||||
let scootaloo_cache_path = config.scootaloo.cache_path.clone();
|
||||
let token = get_oauth2_token(&config.twitter);
|
||||
@@ -59,9 +65,13 @@ pub async fn run(config: Config) {
|
||||
drop(lconn);
|
||||
|
||||
// get user timeline feed (Vec<tweet>)
|
||||
let mut feed =
|
||||
get_user_timeline(&mastodon_config.twitter_screen_name, &token, last_tweet_id)
|
||||
.await?;
|
||||
let mut feed = get_user_timeline(
|
||||
&mastodon_config.twitter_screen_name,
|
||||
&token,
|
||||
last_tweet_id,
|
||||
page_size,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// empty feed -> exiting
|
||||
if feed.is_empty() {
|
||||
|
Reference in New Issue
Block a user