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. https://github.com/the-draupnir-project/Draupnir/issues/504.

* remove `verboseLogging`.

yeah, cya later pal. https://github.com/the-draupnir-project/Draupnir/issues/504.
This commit is contained in:
Gnuxie
2025-02-06 13:43:00 +00:00
committed by GitHub
parent 3ec98e7ad1
commit 711b9b7413
5 changed files with 9 additions and 26 deletions
-4
View File
@@ -74,10 +74,6 @@ verboseLogging: false
# This should be at INFO or DEBUG in order to get support for Draupnir problems.
logLevel: "INFO"
# Whether or not Draupnir should synchronize policy lists immediately after startup.
# Equivalent to running '!draupnir sync'.
syncOnStartup: true
# Whether or not Draupnir should check moderation permissions in all protected rooms on startup.
# Equivalent to running `!draupnir verify`.
verifyPermissionsOnStartup: true
-4
View File
@@ -57,10 +57,6 @@ verboseLogging: false
# This should be at INFO or DEBUG in order to get support for Mjolnir problems.
logLevel: "DEBUG"
# Set to false to disable synchronizing the ban lists on startup. If true, this
# is the same as running !mjolnir sync immediately after startup.
syncOnStartup: true
# Set to false to prevent Mjolnir from checking its permissions on startup. This
# is recommended to be left as "true" to catch room permission problems (state
# resets, etc) before Mjolnir is needed.
-6
View File
@@ -70,10 +70,8 @@ export interface IConfig {
acceptInvitesFromSpace: string | undefined;
recordIgnoredInvites: boolean;
managementRoom: string;
verboseLogging: boolean;
logLevel: "DEBUG" | "INFO" | "WARN" | "ERROR";
logMutedModules: string[];
syncOnStartup: boolean;
verifyPermissionsOnStartup: boolean;
disableServerACL: boolean;
noop: boolean;
@@ -188,10 +186,8 @@ const defaultConfig: IConfig = {
autojoinOnlyIfManager: true,
recordIgnoredInvites: false,
managementRoom: "!noop:example.org",
verboseLogging: false,
logLevel: "INFO",
logMutedModules: ["MatrixHttpClient", "MatrixClientLite"],
syncOnStartup: true,
verifyPermissionsOnStartup: true,
noop: false,
disableServerACL: false,
@@ -373,9 +369,7 @@ export function getProvisionedMjolnirConfig(managementRoomId: string): IConfig {
// on every created Draupnir, which would result in very confusing error messages.
const allowedKeys = [
"commands",
"verboseLogging",
"logLevel",
"syncOnStartup",
"verifyPermissionsOnStartup",
"automaticallyRedactForReasons",
"protectAllJoinedRooms",
+3 -2
View File
@@ -41,7 +41,7 @@ export interface ManagementRoomOutput {
managementRoomID: StringRoomID;
/**
* Log a message to the management room and the console, replaces any room ids in additionalRoomIds with pills.
* @param level Used to determine whether to hide the message or not depending on `config.verboseLogging`.
* @param level Used to determine whether to hide the message or not depending on `config.logLevel`.
* @param module Used to help find where in the source the message is coming from (when logging to the console).
* @param message The message we want to log.
* @param additionalRoomIds The roomIds in the message that we want to be replaced by room pills.
@@ -173,7 +173,8 @@ export default class StandardManagementRoomOutput
if (!Array.isArray(additionalRoomIds))
additionalRoomIds = [additionalRoomIds];
if (this.config.verboseLogging || LogLevel.INFO.includes(level)) {
const levelsIncluded = LogLevel[this.config.logLevel];
if (levelsIncluded.includes(level)) {
let clientMessage = message;
if (level === LogLevel.WARN) clientMessage = `⚠ | ${message}`;
if (level === LogLevel.ERROR) clientMessage = `‼ | ${message}`;
+6 -10
View File
@@ -18,12 +18,13 @@ import {
} from "matrix-bot-sdk";
import { ClientRequest, IncomingMessage } from "http";
import * as Sentry from "@sentry/node";
import ManagementRoomOutput from "./managementroom/ManagementRoomOutput";
import { IConfig } from "./config";
import { Gauge } from "prom-client";
import { MatrixSendClient } from "matrix-protection-suite-for-matrix-bot-sdk";
import { RoomEvent } from "matrix-protection-suite";
import { Logger, RoomEvent } from "matrix-protection-suite";
const log = new Logger("utils");
export function htmlEscape(input: string): string {
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
@@ -103,9 +104,7 @@ export async function redactUserMessagesIn(
noop = false
) {
for (const targetRoomId of targetRoomIds) {
await managementRoom.logMessage(
LogLevel.DEBUG,
"utils#redactUserMessagesIn",
log.debug(
`Fetching sent messages for ${userIdOrGlob} in ${targetRoomId} to redact...`,
targetRoomId
);
@@ -118,9 +117,7 @@ export async function redactUserMessagesIn(
limit,
async (eventsToRedact) => {
for (const victimEvent of eventsToRedact) {
await managementRoom.logMessage(
LogLevel.DEBUG,
"utils#redactUserMessagesIn",
log.debug(
`Redacting ${victimEvent["event_id"]} in ${targetRoomId}`,
targetRoomId
);
@@ -128,8 +125,7 @@ export async function redactUserMessagesIn(
await client
.redactEvent(targetRoomId, victimEvent["event_id"])
.catch((error: unknown) => {
LogService.error(
"utils#redactUserMessagesIn",
log.error(
`Error while trying to redact messages for ${userIdOrGlob} in ${targetRoomId}:`,
error,
targetRoomId