From 75dece474baca43bf84c238db62795156a672218 Mon Sep 17 00:00:00 2001 From: nexryai Date: Tue, 20 Aug 2024 04:25:18 +0000 Subject: [PATCH] fix: NOT blockedHosts list query ref(v12-lts): https://github.com/atsu1125/misskey-v12/commit/3bdc2175dc7a2763cd6add47264c72b960ec6b51 ref(misskey-dev): https://github.com/misskey-dev/misskey/pull/14441 --- .../src/server/api/endpoints/federation/instances.ts | 2 +- .../backend/src/services/chart/charts/federation.ts | 10 +++++----- 2 files 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 7fdbbc1732..7f3fec6aa4 100644 --- a/packages/backend/src/server/api/endpoints/federation/instances.ts +++ b/packages/backend/src/server/api/endpoints/federation/instances.ts @@ -65,7 +65,7 @@ export default define(meta, paramDef, async (ps, me) => { if (ps.blocked) { query.andWhere(meta.blockedHosts.length === 0 ? "1=0" : "instance.host ILIKE ANY(ARRAY[:...blocked])", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }); } else { - query.andWhere(meta.blockedHosts.length === 0 ? "1=1" : "instance.host NOT ILIKE ANY(ARRAY[:...blocked])", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }); + query.andWhere(meta.blockedHosts.length === 0 ? "1=1" : "instance.host NOT ILIKE ALL(ARRAY[:...blocked])", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }); } } diff --git a/packages/backend/src/services/chart/charts/federation.ts b/packages/backend/src/services/chart/charts/federation.ts index 70c9069949..f2db3f7037 100644 --- a/packages/backend/src/services/chart/charts/federation.ts +++ b/packages/backend/src/services/chart/charts/federation.ts @@ -40,21 +40,21 @@ export default class FederationChart extends Chart { Followings.createQueryBuilder("following") .select("COUNT(DISTINCT following.followeeHost)") .where("following.followeeHost IS NOT NULL") - .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "following.followeeHost NOT ILIKE ANY(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) + .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "following.followeeHost NOT ILIKE ALL(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) .andWhere(`following.followeeHost NOT IN (${ suspendedInstancesQuery.getQuery() })`) .getRawOne() .then(x => parseInt(x.count, 10)), Followings.createQueryBuilder("following") .select("COUNT(DISTINCT following.followerHost)") .where("following.followerHost IS NOT NULL") - .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "following.followerHost NOT ILIKE ANY(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) + .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "following.followerHost NOT ILIKE ALL(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) .andWhere(`following.followerHost NOT IN (${ suspendedInstancesQuery.getQuery() })`) .getRawOne() .then(x => parseInt(x.count, 10)), Followings.createQueryBuilder("following") .select("COUNT(DISTINCT following.followeeHost)") .where("following.followeeHost IS NOT NULL") - .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "following.followeeHost NOT ILIKE ANY(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) + .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "following.followeeHost NOT ILIKE ALL(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) .andWhere(`following.followeeHost NOT IN (${ suspendedInstancesQuery.getQuery() })`) .andWhere(`following.followeeHost IN (${ pubsubSubQuery.getQuery() })`) .setParameters(pubsubSubQuery.getParameters()) @@ -63,7 +63,7 @@ export default class FederationChart extends Chart { Instances.createQueryBuilder("instance") .select("COUNT(instance.id)") .where(`instance.host IN (${ subInstancesQuery.getQuery() })`) - .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "instance.host NOT ILIKE ANY(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) + .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "instance.host NOT ILIKE ALL(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) .andWhere("instance.isSuspended = false") .andWhere("instance.lastCommunicatedAt > :gt", { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) }) .getRawOne() @@ -71,7 +71,7 @@ export default class FederationChart extends Chart { Instances.createQueryBuilder("instance") .select("COUNT(instance.id)") .where(`instance.host IN (${ pubInstancesQuery.getQuery() })`) - .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "instance.host NOT ILIKE ANY(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) + .andWhere(meta.blockedHosts.length === 0 ? "1=1" : "instance.host NOT ILIKE ALL(ARRAY[:...blocked]", { blocked: meta.blockedHosts.flatMap(x => [x, `%.${x}`]) }) .andWhere("instance.isSuspended = false") .andWhere("instance.lastCommunicatedAt > :gt", { gt: new Date(Date.now() - (1000 * 60 * 60 * 24 * 30)) }) .getRawOne()