diff --git a/config/config.sample.yaml b/config/config.sample.yaml index a899c18988e333811e3b65c8012500eb98c5cd5f..ed97ed42640ea79345159f5c5868bc810c68778b 100644 --- a/config/config.sample.yaml +++ b/config/config.sample.yaml @@ -27,6 +27,8 @@ bridge: # Disable sending of read receipts for Matrix events which have been # successfully bridged to Discord. disableReadReceipts: false + # Disable Join Leave echos from matrix + disableJoinLeaveNotifications: false # Authentication configuration for the discord bot. auth: clientID: "12345" diff --git a/src/config.ts b/src/config.ts index 060400982c8ca8f53edb9e0382f7b3fc3d9f1453..35d82bd3010d4cb47c9645ab6983a3f55b23c300 100644 --- a/src/config.ts +++ b/src/config.ts @@ -54,6 +54,7 @@ class DiscordBridgeConfigBridge { public disableReadReceipts: boolean; public disableEveryoneMention: boolean = false; public disableHereMention: boolean = false; + public disableJoinLeaveNotifications: boolean = false; } export class DiscordBridgeConfigDatabase { diff --git a/src/matrixeventprocessor.ts b/src/matrixeventprocessor.ts index 1aeae3314a2c1417c1b5f40daad751f3a339f751..a9cd5c7f81c33b0030fee2379106b551762d47fb 100644 --- a/src/matrixeventprocessor.ts +++ b/src/matrixeventprocessor.ts @@ -85,13 +85,21 @@ export class MatrixEventProcessor { const membership = event.content!.membership; if (membership === "join" && event.unsigned.prev_content === undefined) { - msg += `joined the room`; + if (!this.config.bridge.disableJoinLeaveNotifications) { + msg += `joined the room`; + } else { + return + } } else if (membership === "invite") { msg += `invited \`${event.state_key}\` to the room`; } else if (membership === "leave" && event.state_key !== event.sender) { msg += `kicked \`${event.state_key}\` from the room`; } else if (membership === "leave") { - msg += `left the room`; + if (!this.config.bridge.disableJoinLeaveNotifications) { + msg += `left the room`; + } else { + return + } } else if (membership === "ban") { msg += `banned \`${event.state_key}\` from the room`; } @@ -302,7 +310,7 @@ export class MatrixEventProcessor { const mxClient = this.bridge.getClientFactory().getClientAs(); avatarUrl = mxClient.mxcUrlToHttp(profile.avatar_url, DISCORD_AVATAR_WIDTH, DISCORD_AVATAR_HEIGHT); } - } + }disablePresence embed.setAuthor( displayName.substr(0, MAX_NAME_LENGTH), avatarUrl, diff --git a/test/test_config.ts b/test/test_config.ts index ae923241bdb1a18d978cbaa39e52c915ca25577b..4df3c6c823d53673f6972b9adeb49e24396821e3 100644 --- a/test/test_config.ts +++ b/test/test_config.ts @@ -31,6 +31,7 @@ describe("DiscordBridgeConfig.ApplyConfig", () => { disableDiscordMentions: false, disableTypingNotifications: true, enableSelfServiceBridging: false, + disableJoinLeaveNotifications: true, homeserverUrl: "blah", }, logging: { @@ -42,6 +43,7 @@ describe("DiscordBridgeConfig.ApplyConfig", () => { expect(config.bridge.disableDiscordMentions).to.be.false; expect(config.bridge.disableDeletionForwarding).to.be.true; expect(config.bridge.enableSelfServiceBridging).to.be.false; + expect(config.brdge.disableJoinLeaveNotifications).to.be.true expect(config.logging.console, "warn"); }); it("should merge logging.files correctly", () => {