Skip to content

Commit 711b9b7

Browse files
authored
tidy config properties (#724)
* Remove `syncOnStartup` option since it no longer does anything. We always 'sync' on startup, not that we have a concept of syncing anymore. #504. * remove `verboseLogging`. yeah, cya later pal. #504.
1 parent 3ec98e7 commit 711b9b7

File tree

5 files changed

+9
-26
lines changed

5 files changed

+9
-26
lines changed

config/default.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ verboseLogging: false
7474
# This should be at INFO or DEBUG in order to get support for Draupnir problems.
7575
logLevel: "INFO"
7676

77-
# Whether or not Draupnir should synchronize policy lists immediately after startup.
78-
# Equivalent to running '!draupnir sync'.
79-
syncOnStartup: true
80-
8177
# Whether or not Draupnir should check moderation permissions in all protected rooms on startup.
8278
# Equivalent to running `!draupnir verify`.
8379
verifyPermissionsOnStartup: true

config/harness.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ verboseLogging: false
5757
# This should be at INFO or DEBUG in order to get support for Mjolnir problems.
5858
logLevel: "DEBUG"
5959

60-
# Set to false to disable synchronizing the ban lists on startup. If true, this
61-
# is the same as running !mjolnir sync immediately after startup.
62-
syncOnStartup: true
63-
6460
# Set to false to prevent Mjolnir from checking its permissions on startup. This
6561
# is recommended to be left as "true" to catch room permission problems (state
6662
# resets, etc) before Mjolnir is needed.

src/config.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,8 @@ export interface IConfig {
7070
acceptInvitesFromSpace: string | undefined;
7171
recordIgnoredInvites: boolean;
7272
managementRoom: string;
73-
verboseLogging: boolean;
7473
logLevel: "DEBUG" | "INFO" | "WARN" | "ERROR";
7574
logMutedModules: string[];
76-
syncOnStartup: boolean;
7775
verifyPermissionsOnStartup: boolean;
7876
disableServerACL: boolean;
7977
noop: boolean;
@@ -188,10 +186,8 @@ const defaultConfig: IConfig = {
188186
autojoinOnlyIfManager: true,
189187
recordIgnoredInvites: false,
190188
managementRoom: "!noop:example.org",
191-
verboseLogging: false,
192189
logLevel: "INFO",
193190
logMutedModules: ["MatrixHttpClient", "MatrixClientLite"],
194-
syncOnStartup: true,
195191
verifyPermissionsOnStartup: true,
196192
noop: false,
197193
disableServerACL: false,
@@ -373,9 +369,7 @@ export function getProvisionedMjolnirConfig(managementRoomId: string): IConfig {
373369
// on every created Draupnir, which would result in very confusing error messages.
374370
const allowedKeys = [
375371
"commands",
376-
"verboseLogging",
377372
"logLevel",
378-
"syncOnStartup",
379373
"verifyPermissionsOnStartup",
380374
"automaticallyRedactForReasons",
381375
"protectAllJoinedRooms",

src/managementroom/ManagementRoomOutput.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface ManagementRoomOutput {
4141
managementRoomID: StringRoomID;
4242
/**
4343
* Log a message to the management room and the console, replaces any room ids in additionalRoomIds with pills.
44-
* @param level Used to determine whether to hide the message or not depending on `config.verboseLogging`.
44+
* @param level Used to determine whether to hide the message or not depending on `config.logLevel`.
4545
* @param module Used to help find where in the source the message is coming from (when logging to the console).
4646
* @param message The message we want to log.
4747
* @param additionalRoomIds The roomIds in the message that we want to be replaced by room pills.
@@ -173,7 +173,8 @@ export default class StandardManagementRoomOutput
173173
if (!Array.isArray(additionalRoomIds))
174174
additionalRoomIds = [additionalRoomIds];
175175

176-
if (this.config.verboseLogging || LogLevel.INFO.includes(level)) {
176+
const levelsIncluded = LogLevel[this.config.logLevel];
177+
if (levelsIncluded.includes(level)) {
177178
let clientMessage = message;
178179
if (level === LogLevel.WARN) clientMessage = `⚠ | ${message}`;
179180
if (level === LogLevel.ERROR) clientMessage = `‼ | ${message}`;

src/utils.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ import {
1818
} from "matrix-bot-sdk";
1919
import { ClientRequest, IncomingMessage } from "http";
2020
import * as Sentry from "@sentry/node";
21-
2221
import ManagementRoomOutput from "./managementroom/ManagementRoomOutput";
2322
import { IConfig } from "./config";
2423
import { Gauge } from "prom-client";
2524
import { MatrixSendClient } from "matrix-protection-suite-for-matrix-bot-sdk";
26-
import { RoomEvent } from "matrix-protection-suite";
25+
import { Logger, RoomEvent } from "matrix-protection-suite";
26+
27+
const log = new Logger("utils");
2728

2829
export function htmlEscape(input: string): string {
2930
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
@@ -103,9 +104,7 @@ export async function redactUserMessagesIn(
103104
noop = false
104105
) {
105106
for (const targetRoomId of targetRoomIds) {
106-
await managementRoom.logMessage(
107-
LogLevel.DEBUG,
108-
"utils#redactUserMessagesIn",
107+
log.debug(
109108
`Fetching sent messages for ${userIdOrGlob} in ${targetRoomId} to redact...`,
110109
targetRoomId
111110
);
@@ -118,18 +117,15 @@ export async function redactUserMessagesIn(
118117
limit,
119118
async (eventsToRedact) => {
120119
for (const victimEvent of eventsToRedact) {
121-
await managementRoom.logMessage(
122-
LogLevel.DEBUG,
123-
"utils#redactUserMessagesIn",
120+
log.debug(
124121
`Redacting ${victimEvent["event_id"]} in ${targetRoomId}`,
125122
targetRoomId
126123
);
127124
if (!noop) {
128125
await client
129126
.redactEvent(targetRoomId, victimEvent["event_id"])
130127
.catch((error: unknown) => {
131-
LogService.error(
132-
"utils#redactUserMessagesIn",
128+
log.error(
133129
`Error while trying to redact messages for ${userIdOrGlob} in ${targetRoomId}:`,
134130
error,
135131
targetRoomId

0 commit comments

Comments
 (0)