From 4ff88d73a76ffd222b19389c8ecb38df60aec647 Mon Sep 17 00:00:00 2001 From: atsu1125 Date: Thu, 9 Nov 2023 21:18:15 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20Judge=20instance=20block=20=E3=82=B5?= =?UTF-8?q?=E3=83=BC=E3=83=90=E3=83=BC=E3=82=B5=E3=82=A4=E3=83=AC=E3=83=B3?= =?UTF-8?q?=E3=82=B9=20by=20endsWith?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/server/api/endpoints/federation/instances.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/federation/instances.ts b/packages/backend/src/server/api/endpoints/federation/instances.ts index c8beefa9c775..e44335d593f2 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -81,9 +81,9 @@ export default class extends Endpoint { // eslint- if (typeof ps.blocked === 'boolean') { const meta = await this.metaService.fetch(true); if (ps.blocked) { - query.andWhere(meta.blockedHosts.length === 0 ? '1=0' : 'instance.host IN (:...blocks)', { blocks: meta.blockedHosts }); + query.andWhere(meta.blockedHosts.length === 0 ? '1=0' : 'instance.host ILIKE ANY(ARRAY[:...blocks])', { blocks: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }); } else { - query.andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'instance.host NOT IN (:...blocks)', { blocks: meta.blockedHosts }); + query.andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'instance.host NOT ILIKE ANY(ARRAY[:...blocks])', { blocks: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }); } } @@ -110,12 +110,12 @@ export default class extends Endpoint { // eslint- if (meta.silencedHosts.length === 0) { return []; } - query.andWhere("instance.host IN (:...silences)", { - silences: meta.silencedHosts, + query.andWhere("instance.host ILIKE ANY(ARRAY[:...silences])", { + silences: meta.silencedHosts.flatMap(x => [x, `%.${x}`]), }); } else if (meta.silencedHosts.length > 0) { - query.andWhere("instance.host NOT IN (:...silences)", { - silences: meta.silencedHosts, + query.andWhere("instance.host NOT ILIKE ANY(ARRAY[:...silences])", { + silences: meta.silencedHosts.flatMap(x => [x, `%.${x}`]), }); } }