nicer SQL checks for blocked hosts
instead of passing a (possibly gigantic) array from JS, we get PostgreSQL to look at the value in the `meta` table directly tested the `federation/instances` endpoint, and the `QueryService` methods; I have not tested the charts
This commit is contained in:
parent
54b5c930cb
commit
31d93c8052
3 changed files with 8 additions and 9 deletions
|
|
@ -115,9 +115,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 IN (select unnest("blockedHosts") as x from "meta")');
|
||||
} 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 IN (select unnest("blockedHosts") as x from "meta")');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue