merge: on 429, retry fetchAccount instead of failing (!817)

View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/817

Approved-by: Hazelnoot <acomputerdog@gmail.com>
Approved-by: Marie <github@yuugi.dev>
This commit is contained in:
dakkar 2024-12-13 18:33:36 +00:00
commit 9dc03858bd
2 changed files with 8 additions and 1 deletions

View file

@ -340,7 +340,7 @@ export class ApiCallService implements OnApplicationShutdown {
code: 'RATE_LIMIT_EXCEEDED', code: 'RATE_LIMIT_EXCEEDED',
id: 'd5826d14-3982-4d2e-8011-b9e9f02499ef', id: 'd5826d14-3982-4d2e-8011-b9e9f02499ef',
httpStatusCode: 429, httpStatusCode: 429,
}); }, info);
} }
} }
} }

View file

@ -147,6 +147,13 @@ function fetchAccount(token: string, id?: string, forceShowDialog?: boolean): Pr
text: i18n.ts.tokenRevokedDescription, text: i18n.ts.tokenRevokedDescription,
}); });
} }
} else if (res.error.id === 'd5826d14-3982-4d2e-8011-b9e9f02499ef') {
// rate limited
const timeToWait = res.error.info?.resetMs ?? 1000;
window.setTimeout(timeToWait, () => {
fetchAccount(token, id, forceShowDialog).then(done, fail);
});
return;
} else { } else {
await alert({ await alert({
type: 'error', type: 'error',