Skip to content

Commit

Permalink
Merge pull request #2226 from h3poteto/fix/link_header
Browse files Browse the repository at this point in the history
Skip link header if it is the final page
  • Loading branch information
h3poteto authored Nov 5, 2024
2 parents 43bb7ac + d7073c6 commit f371978
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions megalodon/src/friendica.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ export default class Friendica implements MegalodonInterface {
converted = Object.assign({}, converted, {
data: [...converted.data, ...nextRes.data.map(a => FriendicaAPI.Converter.account(a))]
})
if (nextRes.headers.link === undefined) {
break
}
parsed = parseLinkHeader(nextRes.headers.link)
if (sleep_ms) {
await new Promise<void>(converted => setTimeout(converted, sleep_ms))
Expand Down
3 changes: 3 additions & 0 deletions megalodon/src/mastodon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,9 @@ export default class Mastodon implements MegalodonInterface {
converted = Object.assign({}, converted, {
data: [...converted.data, ...nextRes.data.map(a => MastodonAPI.Converter.account(a))]
})
if (nextRes.headers.link === undefined) {
break
}
parsed = parseLinkHeader(nextRes.headers.link)
if (sleep_ms) {
await new Promise<void>(converted => setTimeout(converted, sleep_ms))
Expand Down

0 comments on commit f371978

Please sign in to comment.