server: fix instance skipping

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 untrusted user: 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;