diff --git a/src/index.ts b/src/index.ts index 8149a5c..0d61a4e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -70,11 +70,11 @@ if (config.health.healthz.enabled) { } // Switch to using the rule server if we need to + const banLists: BanList[] = []; if (config.ruleServer?.enabled) { await logMessage(LogLevel.INFO, "index", "Rule server is starting up."); // Resolve all the rule server's watched rooms - const banLists: BanList[] = []; for (const roomRef of config.ruleServer.listRooms) { const permalink = Permalinks.parseUrl(roomRef); if (!permalink.roomIdOrAlias) continue; @@ -121,7 +121,6 @@ if (config.health.healthz.enabled) { return client.joinRoom(roomId); }); - const banLists: BanList[] = []; const protectedRooms: { [roomId: string]: string } = {}; // Ensure we're also joined to the rooms we're protecting diff --git a/src/modules/RuleServer.ts b/src/modules/RuleServer.ts index cbf9d91..2388718 100644 --- a/src/modules/RuleServer.ts +++ b/src/modules/RuleServer.ts @@ -72,11 +72,13 @@ export class RuleServer { } private async rebuildRules() { - const userRules = this.banLists.map(b => b.userRules).reduce((a, c) => {a.push(...c); return a;}, []); - const roomRules = this.banLists.map(b => b.roomRules).reduce((a, c) => {a.push(...c); return a;}, []); - const serverRules = this.banLists.map(b => b.serverRules).reduce((a, c) => {a.push(...c); return a;}, []); - - console.log({userRules, roomRules, serverRules}); + const doReduce = (a, c) => { + a.push(...c); + return a; + }; + const userRules = this.banLists.map(b => b.userRules).reduce(doReduce, []); + const roomRules = this.banLists.map(b => b.roomRules).reduce(doReduce, []); + const serverRules = this.banLists.map(b => b.serverRules).reduce(doReduce, []); this.pyRules = { checks: {