replace skipped.includes with some(sameOrSubdomainOf)
Some checks failed
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/lint-foundkey-js Pipeline was successful
ci/woodpecker/pr/lint-backend Pipeline failed
ci/woodpecker/pr/lint-client Pipeline failed
ci/woodpecker/pr/test Pipeline failed

This commit is contained in:
Norm 2022-12-01 03:02:14 -05:00
parent c97c29ad0f
commit 154a0de60f
Signed by: norm
GPG key ID: 7123E30E441E80DE

View file

@ -29,9 +29,8 @@ export async function shouldBlockInstance(host: Instance['host']): Promise<boole
return true;
}
const result: { exists: boolean } = await db.query('SELECT EXISTS(SELECT "host" FROM instance WHERE ("host" = $1 OR "host" LIKE $2) AND "isSuspended") AS "exists"', [
const result: { exists: boolean } = await db.query('SELECT EXISTS(SELECT "host" FROM instance WHERE ("host" = $1 OR "host" LIKE \'%.\' || $1) AND "isSuspended") AS "exists"', [
host,
'%.' + host,
]);
return result.exists;
}
@ -59,7 +58,7 @@ export async function skippedInstances(hosts: Array<Instance['host']>): Promise<
deadTime.toISOString(),
// don't check hosts again that we already know are suspended
// also avoids adding duplicates to the list
hosts.filter(host => !skipped.includes(host) && !host.includes(',')).join(','),
hosts.filter(host => !skipped.some(blockedHost => sameOrSubdomainOf(host, blockedHost)) && !host.includes(',')).join(','),
],
)
.then(res => res.map(row => row.host)),