Skip to content

Commit

Permalink
Merge pull request #107 from serafuku/yunochi/develop
Browse files Browse the repository at this point in the history
🐛 마스토돈 팔로잉 50명 이하일때 수정
  • Loading branch information
yunochi authored Dec 15, 2024
2 parents f8c5b3a + 90d7bb1 commit 229bab2
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 229bab2

Please sign in to comment.