Skip to content

Commit

Permalink
Fix: Judge instance block サーバーサイレンス by endsWith
Browse files Browse the repository at this point in the history
  • Loading branch information
atsu1125 committed Nov 9, 2023
1 parent e2cac3d commit 4ff88d7
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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}`]) });
}
}

Expand All @@ -110,12 +110,12 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // 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}`]),
});
}
}
Expand Down

0 comments on commit 4ff88d7

Please sign in to comment.