Skip to content

Commit

Permalink
refactor: cache set in signin function
Browse files Browse the repository at this point in the history
  • Loading branch information
zyoshoka committed Oct 12, 2024
1 parent 1a3ed18 commit f2226d8
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/backend/test-federation/test/utils.ts
Original file line number Diff line number Diff line change
@@ -51,6 +51,7 @@ async function signin(
return await (new Misskey.api.APIClient({ origin: `https://${host}` }).request as Request)('signin-flow', params)
.then(res => {
strictEqual(res.finished, true);
if (params.username === ADMIN_PARAMS.username) ADMIN_CACHE.set(host, res);
return res;
})
.then(({ id, i }) => ({ id, i }))
@@ -88,10 +89,6 @@ async function createAdmin(host: Host): Promise<Misskey.entities.SignupResponse

export async function fetchAdmin(host: Host): Promise<LoginUser> {
const admin = ADMIN_CACHE.get(host) ?? await signin(host, ADMIN_PARAMS)
.then(res => {
ADMIN_CACHE.set(host, res);
return res;
})
.catch(async err => {
if (err.id === '6cc579cc-885d-43d8-95c2-b8c7fc963280') {
await createAdmin(host);

0 comments on commit f2226d8

Please sign in to comment.