diff options
author | dakkar <dakkar@thenautilus.net> | 2023-02-24 12:37:42 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2023-02-24 12:47:41 +0000 |
commit | 9dbd8be35891bb83abad647f9f488aa9a64722da (patch) | |
tree | cb68eef882a2d41955d9ec8ca7af80714b5a6a7d /tweet-archive.pl | |
parent | config example (diff) | |
download | tweet-archive-9dbd8be35891bb83abad647f9f488aa9a64722da.tar.gz tweet-archive-9dbd8be35891bb83abad647f9f488aa9a64722da.tar.bz2 tweet-archive-9dbd8be35891bb83abad647f9f488aa9a64722da.zip |
Fix pagination of Misskey responses
Misskey API, with `sinceId`, pages by `id ASC`, not descending as I
thought.
Also, allow using callbacks for paginated queries instead of
accumulating all results (much nicer for the initial db filling)
Diffstat (limited to 'tweet-archive.pl')
-rw-r--r-- | tweet-archive.pl | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/tweet-archive.pl b/tweet-archive.pl index 1a7232b..38bb184 100644 --- a/tweet-archive.pl +++ b/tweet-archive.pl @@ -63,11 +63,14 @@ if ($conf->{misskey}) { $client->client->ua->add_handler( response_done => sub { push @responses, $_[0]; return } ); try { - my $latest_id = $store->latest_note_id; + my $latest_id = $store->latest_note_id // '0'; - for my $note ($client->timeline($latest_id)->@*) { - $store->store_note($note); - } + $client->timeline( + $latest_id, + sub($notes) { + $store->store_note($_) for $notes->@*; + }, + ); $store->store_misskey_following($client->following); $store->store_misskey_followers($client->followers); |