mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-08 13:04:34 +00:00
apply optimized domain block pattern to silence and bubble checks
This commit is contained in:
parent
f4dafd709c
commit
ff8b22ce60
1 changed files with 8 additions and 27 deletions
|
@ -113,11 +113,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof ps.blocked === 'boolean') {
|
if (typeof ps.blocked === 'boolean') {
|
||||||
const meta = await this.metaService.fetch(true);
|
|
||||||
if (ps.blocked) {
|
if (ps.blocked) {
|
||||||
query.andWhere(meta.blockedHosts.length === 0 ? '1=0' : 'instance.host IN (select unnest("blockedHosts") as x from "meta")');
|
query.andWhere('instance.host IN (select unnest("blockedHosts") as x from "meta")');
|
||||||
} else {
|
} else {
|
||||||
query.andWhere(meta.blockedHosts.length === 0 ? '1=1' : 'instance.host NOT IN (select unnest("blockedHosts") as x from "meta")');
|
query.andWhere('instance.host NOT IN (select unnest("blockedHosts") as x from "meta")');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,36 +145,18 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof ps.silenced === 'boolean') {
|
if (typeof ps.silenced === 'boolean') {
|
||||||
const meta = await this.metaService.fetch(true);
|
|
||||||
|
|
||||||
if (ps.silenced) {
|
if (ps.silenced) {
|
||||||
if (meta.silencedHosts.length === 0) {
|
query.andWhere('instance.host IN (select unnest("silencedHosts") as x from "meta")');
|
||||||
return [];
|
} else {
|
||||||
}
|
query.andWhere('instance.host NOT IN (select unnest("silencedHosts") as x from "meta")');
|
||||||
query.andWhere('instance.host IN (:...silences)', {
|
|
||||||
silences: meta.silencedHosts,
|
|
||||||
});
|
|
||||||
} else if (meta.silencedHosts.length > 0) {
|
|
||||||
query.andWhere('instance.host NOT IN (:...silences)', {
|
|
||||||
silences: meta.silencedHosts,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof ps.bubble === 'boolean') {
|
if (typeof ps.bubble === 'boolean') {
|
||||||
const meta = await this.metaService.fetch(true);
|
|
||||||
|
|
||||||
if (ps.bubble) {
|
if (ps.bubble) {
|
||||||
if (meta.bubbleInstances.length === 0) {
|
query.andWhere('instance.host IN (select unnest("bubbleInstances") as x from "meta")');
|
||||||
return [];
|
} else {
|
||||||
}
|
query.andWhere('instance.host NOT IN (select unnest("bubbleInstances") as x from "meta")');
|
||||||
query.andWhere('instance.host IN (:...bubble)', {
|
|
||||||
bubble: meta.bubbleInstances,
|
|
||||||
});
|
|
||||||
} else if (meta.bubbleInstances.length > 0) {
|
|
||||||
query.andWhere('instance.host NOT IN (:...bubble)', {
|
|
||||||
bubble: meta.bubbleInstances,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue