server: fix instance skipping
All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/test Pipeline was successful

This should actually make instance skipping work properly since
shouldBlockInstance is now properly awaited on now.
This commit is contained in:
Norm 2022-12-02 09:10:20 -05:00
parent 9ad37a12f8
commit 5e6b51094e
Signed by: norm
GPG key ID: 7123E30E441E80DE

View file

@ -40,7 +40,10 @@ export async function shouldBlockInstance(host: string): Promise<boolean> {
* @returns array of punycoded instance hosts that should be skipped (subset of hosts parameter)
*/
export async function skippedInstances(hosts: Array<Instance['host']>): Promise<Array<Instance['host']>> {
const skipped = hosts.filter(host => shouldBlockInstance(host));
// Resolve the boolean promises before filtering
const shouldSkip = await Promise.all(hosts.map(shouldBlockInstance));
const skipped = hosts.filter((_, i) => shouldSkip[i]);
// if possible return early and skip accessing the database
if (skipped.length === hosts.length) return hosts;