Skip to content
Extraits de code Groupes Projets
Valider 122fbb99 rédigé par Florent F's avatar Florent F
Parcourir les fichiers

Add disableInviteNotifications option to drop invitations notifs

parent 3eb658bf
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -29,6 +29,8 @@ bridge: ...@@ -29,6 +29,8 @@ bridge:
disableReadReceipts: false disableReadReceipts: false
# Disable Join Leave echos from matrix # Disable Join Leave echos from matrix
disableJoinLeaveNotifications: false disableJoinLeaveNotifications: false
# Disable Invite echos from matrix
disableInviteNotifications: false
# Authentication configuration for the discord bot. # Authentication configuration for the discord bot.
auth: auth:
# This MUST be a string (wrapped in quotes) # This MUST be a string (wrapped in quotes)
......
...@@ -22,6 +22,10 @@ properties: ...@@ -22,6 +22,10 @@ properties:
type: "boolean" type: "boolean"
disableReadReceipts: disableReadReceipts:
type: "boolean" type: "boolean"
disableJoinLeaveNotifications:
type: "boolean"
disableInviteNotifications:
type: "boolean"
auth: auth:
type: "object" type: "object"
required: ["botToken", "clientID"] required: ["botToken", "clientID"]
......
...@@ -90,6 +90,7 @@ class DiscordBridgeConfigBridge { ...@@ -90,6 +90,7 @@ class DiscordBridgeConfigBridge {
public disableEveryoneMention: boolean = false; public disableEveryoneMention: boolean = false;
public disableHereMention: boolean = false; public disableHereMention: boolean = false;
public disableJoinLeaveNotifications: boolean = false; public disableJoinLeaveNotifications: boolean = false;
public disableInviteNotifications: boolean = false;
public enableMetrics: boolean = false; public enableMetrics: boolean = false;
} }
......
...@@ -231,6 +231,7 @@ export class MatrixEventProcessor { ...@@ -231,6 +231,7 @@ export class MatrixEventProcessor {
let msg = `\`${event.sender}\` `; let msg = `\`${event.sender}\` `;
const allowJoinLeave = !this.config.bridge.disableJoinLeaveNotifications; const allowJoinLeave = !this.config.bridge.disableJoinLeaveNotifications;
const allowInvite = !this.config.bridge.disableInviteNotifications;
if (event.type === "m.room.name") { if (event.type === "m.room.name") {
msg += `set the name to \`${event.content!.name}\``; msg += `set the name to \`${event.content!.name}\``;
...@@ -255,7 +256,7 @@ export class MatrixEventProcessor { ...@@ -255,7 +256,7 @@ export class MatrixEventProcessor {
} }
if (membership === "join" && isNewJoin && allowJoinLeave) { if (membership === "join" && isNewJoin && allowJoinLeave) {
msg += "joined the room"; msg += "joined the room";
} else if (membership === "invite") { } else if (membership === "invite" && allowInvite) {
msg += `invited \`${event.state_key}\` to the room`; msg += `invited \`${event.state_key}\` to the room`;
} else if (membership === "leave" && event.state_key !== event.sender) { } else if (membership === "leave" && event.state_key !== event.sender) {
msg += `kicked \`${event.state_key}\` from the room`; msg += `kicked \`${event.state_key}\` from the room`;
......
...@@ -30,6 +30,7 @@ describe("DiscordBridgeConfig.applyConfig", () => { ...@@ -30,6 +30,7 @@ describe("DiscordBridgeConfig.applyConfig", () => {
disableDeletionForwarding: true, disableDeletionForwarding: true,
disableDiscordMentions: false, disableDiscordMentions: false,
disableJoinLeaveNotifications: true, disableJoinLeaveNotifications: true,
disableInviteNotifications: true,
disableTypingNotifications: true, disableTypingNotifications: true,
enableSelfServiceBridging: false, enableSelfServiceBridging: false,
homeserverUrl: "blah", homeserverUrl: "blah",
...@@ -44,6 +45,7 @@ describe("DiscordBridgeConfig.applyConfig", () => { ...@@ -44,6 +45,7 @@ describe("DiscordBridgeConfig.applyConfig", () => {
expect(config.bridge.disableDeletionForwarding).to.be.true; expect(config.bridge.disableDeletionForwarding).to.be.true;
expect(config.bridge.enableSelfServiceBridging).to.be.false; expect(config.bridge.enableSelfServiceBridging).to.be.false;
expect(config.bridge.disableJoinLeaveNotifications).to.be.true; expect(config.bridge.disableJoinLeaveNotifications).to.be.true;
expect(config.bridge.disableInviteNotifications).to.be.true;
expect(config.logging.console).to.equal("warn"); expect(config.logging.console).to.equal("warn");
}); });
it("should merge environment overrides correctly", () => { it("should merge environment overrides correctly", () => {
...@@ -61,9 +63,11 @@ describe("DiscordBridgeConfig.applyConfig", () => { ...@@ -61,9 +63,11 @@ describe("DiscordBridgeConfig.applyConfig", () => {
config.applyEnvironmentOverrides({ config.applyEnvironmentOverrides({
APPSERVICE_DISCORD_BRIDGE_DISABLE_DELETION_FORWARDING: false, APPSERVICE_DISCORD_BRIDGE_DISABLE_DELETION_FORWARDING: false,
APPSERVICE_DISCORD_BRIDGE_DISABLE_JOIN_LEAVE_NOTIFICATIONS: true, APPSERVICE_DISCORD_BRIDGE_DISABLE_JOIN_LEAVE_NOTIFICATIONS: true,
APPSERVICE_DISCORD_BRIDGE_DISABLE_INVITE_NOTIFICATIONS: true,
APPSERVICE_DISCORD_LOGGING_CONSOLE: "debug", APPSERVICE_DISCORD_LOGGING_CONSOLE: "debug",
}); });
expect(config.bridge.disableJoinLeaveNotifications).to.be.true; expect(config.bridge.disableJoinLeaveNotifications).to.be.true;
expect(config.bridge.disableInviteNotifications).to.be.true;
expect(config.bridge.disableDeletionForwarding).to.be.false; expect(config.bridge.disableDeletionForwarding).to.be.false;
expect(config.bridge.disableDiscordMentions).to.be.false; expect(config.bridge.disableDiscordMentions).to.be.false;
expect(config.bridge.homeserverUrl).to.equal("blah"); expect(config.bridge.homeserverUrl).to.equal("blah");
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter