Allow blank MATRIX_BLACKLIST and MATRIX_WHITELIST

This commit is contained in:
bertybuttface 2023-01-08 00:15:03 +00:00
parent bf440d7135
commit 0d6120c1bb
2 changed files with 3 additions and 2 deletions

View File

@ -57,6 +57,7 @@ MATRIX_DEFAULT_PREFIX_REPLY=false
# Matrix Access Control (optional)
# Can be set to user:homeserver or a wildcard like :anotherhomeserver.example
MATRIX_BLACKLIST=
# `MATRIX_WHITELIST` is overriden by `MATRIX_BLACKLIST`
MATRIX_WHITELIST=
# Matrix Feature Flags (optional)

View File

@ -40,10 +40,10 @@ export default class CommandHandler {
if (Date.now() - event.origin_server_ts > 10000) return; // Ignore old messages
const relatesTo: RelatesTo | undefined = event.content["m.relates_to"];
if ((relatesTo !== undefined) && (relatesTo["rel_type"] === "m.replace")) return; // Ignore edits
if (MATRIX_BLACKLIST !== undefined){
if ((MATRIX_BLACKLIST !== undefined) && MATRIX_BLACKLIST){
if (MATRIX_BLACKLIST.split(" ").find(b => event.sender.endsWith(b))) return; // Ignore if on blacklist if set
}
if (MATRIX_WHITELIST !== undefined){
if ((MATRIX_WHITELIST !== undefined) && MATRIX_WHITELIST){
if (!MATRIX_WHITELIST.split(" ").find(w => event.sender.endsWith(w))) return; // Ignore if not on whitelist if set
}
const rootEventId: string = (relatesTo !== undefined && relatesTo.event_id !== undefined) ? relatesTo.event_id : event.event_id;