Skip to content

Commit

Permalink
πŸ› λ§ˆμŠ€ν† λˆ νŒ”λ‘œμž‰ 50λͺ… μ΄ν•˜μΌλ•Œ μˆ˜μ •
Browse files Browse the repository at this point in the history
- 50λͺ… μ΄ν•˜μΈ κ²½μš°λŠ” link 헀더 자체λ₯Ό μ•ˆ μ£ΌλŠ”λ“―???
  • Loading branch information
yunochi committed Dec 15, 2024
1 parent 18518a5 commit 90d7bb1
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/app/api/_service/queue/workers/RefreshFollowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,17 +177,6 @@ export class RefreshFollowWorkerService {
}
const data = (await res.json()) as MastodonUser[];
counter += data.length;

const link_header = res.headers.get('link');
if (!link_header) {
throw new UnrecoverableError(`Mastodon Server does not give Next header`);
}

if (data.length === 0) {
logger.log(`${counter} follow imported`);
break;
}

for (const f of data) {
const followeeDomain = new URL(f.url).hostname;
const followeeHandle = `@${f.username}@${followeeDomain}`;
Expand All @@ -209,6 +198,17 @@ export class RefreshFollowWorkerService {
}
logger.debug(`Processed ${counter} follows...`);

if (data.length === 0) {
logger.log(`${counter} follow imported`);
break;
}
const link_header = res.headers.get('link');
if (!link_header) {
logger.debug(`Mastodon Server does not give link Header (Maybe End of list)`);
logger.log(`${counter} follow imported`);
break;
}

const next_url = link_header.match(/(?:<)(https:\/\/.+)(?:>; rel="next")/)?.[1];
if (!next_url) {
logger.debug(`Mastodon Server does not give Next URL (End of list)`);
Expand Down

0 comments on commit 90d7bb1

Please sign in to comment.