mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
add utility service overloads for quickly checking hosts against meta values
This commit is contained in:
parent
305250d073
commit
b422d5bc9d
1 changed files with 33 additions and 6 deletions
|
@ -49,22 +49,49 @@ export class UtilityService {
|
||||||
return regexp.test(email);
|
return regexp.test(email);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isBlockedHost(host: string | null): boolean;
|
||||||
|
public isBlockedHost(blockedHosts: string[], host: string | null): boolean;
|
||||||
@bindThis
|
@bindThis
|
||||||
public isBlockedHost(blockedHosts: string[], host: string | null): boolean {
|
public isBlockedHost(blockedHostsOrHost: string[] | string | null, host?: string | null): boolean {
|
||||||
|
const blockedHosts = Array.isArray(blockedHostsOrHost) ? blockedHostsOrHost : this.meta.blockedHosts;
|
||||||
|
host = Array.isArray(blockedHostsOrHost) ? host : blockedHostsOrHost;
|
||||||
|
|
||||||
if (host == null) return false;
|
if (host == null) return false;
|
||||||
return blockedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
|
return blockedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isSilencedHost(host: string | null): boolean;
|
||||||
|
public isSilencedHost(silencedHosts: string[], host: string | null): boolean;
|
||||||
@bindThis
|
@bindThis
|
||||||
public isSilencedHost(silencedHosts: string[] | undefined, host: string | null): boolean {
|
public isSilencedHost(silencedHostsOrHost: string[] | string | null, host?: string | null): boolean {
|
||||||
if (!silencedHosts || host == null) return false;
|
const silencedHosts = Array.isArray(silencedHostsOrHost) ? silencedHostsOrHost : this.meta.silencedHosts;
|
||||||
|
host = Array.isArray(silencedHostsOrHost) ? host : silencedHostsOrHost;
|
||||||
|
|
||||||
|
if (host == null) return false;
|
||||||
return silencedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
|
return silencedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public isMediaSilencedHost(host: string | null): boolean;
|
||||||
|
public isMediaSilencedHost(silencedHosts: string[], host: string | null): boolean;
|
||||||
@bindThis
|
@bindThis
|
||||||
public isMediaSilencedHost(silencedHosts: string[] | undefined, host: string | null): boolean {
|
public isMediaSilencedHost(mediaSilencedHostsOrHost: string[] | string | null, host?: string | null): boolean {
|
||||||
if (!silencedHosts || host == null) return false;
|
const mediaSilencedHosts = Array.isArray(mediaSilencedHostsOrHost) ? mediaSilencedHostsOrHost : this.meta.mediaSilencedHosts;
|
||||||
return silencedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
|
host = Array.isArray(mediaSilencedHostsOrHost) ? host : mediaSilencedHostsOrHost;
|
||||||
|
|
||||||
|
if (host == null) return false;
|
||||||
|
return mediaSilencedHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public isAllowListedHost(host: string | null): boolean {
|
||||||
|
if (host == null) return false;
|
||||||
|
return this.meta.federationHosts.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
|
||||||
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
public isBubbledHost(host: string | null): boolean {
|
||||||
|
if (host == null) return false;
|
||||||
|
return this.meta.bubbleInstances.some(x => `.${host.toLowerCase()}`.endsWith(`.${x}`));
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
|
Loading…
Add table
Reference in a new issue