From d0165c58ab0011745d57bfee6ca7418cca1e3cf6 Mon Sep 17 00:00:00 2001 From: "felix.stupp@banananet.work" Date: Thu, 27 Jul 2023 14:30:06 +0000 Subject: [PATCH] use botJoinMessage from config with default being the same as before --- config/config.default.json | 1 + server/lib/matrix-utils/ensure-room-joined.js | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config/config.default.json b/config/config.default.json index 3af9d99..6f78cc3 100644 --- a/config/config.default.json +++ b/config/config.default.json @@ -5,6 +5,7 @@ // (see readme for more details) "matrixServerUrl": "http://localhost:8008/", "matrixServerName": "localhost", + // "botJoinMessage": "Joining room … See FAQ _" (full default in code) // Set this to 100 since that is the max that Synapse will backfill even if you do a // `/messages?limit=1000` and we don't want to miss messages in between. "messageLimit": 100, diff --git a/server/lib/matrix-utils/ensure-room-joined.js b/server/lib/matrix-utils/ensure-room-joined.js index ee3b964..430596e 100644 --- a/server/lib/matrix-utils/ensure-room-joined.js +++ b/server/lib/matrix-utils/ensure-room-joined.js @@ -16,6 +16,16 @@ assert(matrixServerUrl); const matrixViewerURLCreator = new MatrixViewerURLCreator(basePath); +const defaultJoinMessage = `Joining room to check history visibility. ` + + `If your room is public with shared or world readable history visibility, ` + + `it will be accessible on ${matrixViewerURLCreator.roomDirectoryUrl()}. ` + + `See the FAQ for more details: ` + + `https://github.com/matrix-org/matrix-viewer/blob/main/docs/faq.md#why-did-the-bot-join-my-room`; + +config.defaults({ + botJoinMessage: defaultJoinMessage, +}); + async function ensureRoomJoined( accessToken, roomIdOrAlias, @@ -49,12 +59,7 @@ async function ensureRoomJoined( accessToken, abortSignal, body: { - reason: - `Joining room to check history visibility. ` + - `If your room is public with shared or world readable history visibility, ` + - `it will be accessible on ${matrixViewerURLCreator.roomDirectoryUrl()}. ` + - `See the FAQ for more details: ` + - `https://github.com/matrix-org/matrix-viewer/blob/main/docs/faq.md#why-did-the-bot-join-my-room`, + reason: config.get("botJoinMessage"), }, }); assert(