From 464a7ee7653ee49ab818026dd738cee5b9856969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=ADrez=20Franco?= Date: Fri, 26 Feb 2021 16:10:57 +0200 Subject: [PATCH] Add config option to disable bridging m.notices Closes #259 --- config/bridge.go | 2 ++ example-config.yaml | 2 ++ portal.go | 3 +++ 3 files changed, 7 insertions(+) diff --git a/config/bridge.go b/config/bridge.go index f55c997..e30c62e 100644 --- a/config/bridge.go +++ b/config/bridge.go @@ -69,6 +69,7 @@ type BridgeConfig struct { InviteOwnPuppetForBackfilling bool `yaml:"invite_own_puppet_for_backfilling"` PrivateChatPortalMeta bool `yaml:"private_chat_portal_meta"` + BridgeNotices bool `yaml:"bridge_notices"` ResendBridgeInfo bool `yaml:"resend_bridge_info"` WhatsappThumbnail bool `yaml:"whatsapp_thumbnail"` @@ -129,6 +130,7 @@ func (bc *BridgeConfig) setDefaults() { bc.InviteOwnPuppetForBackfilling = true bc.PrivateChatPortalMeta = false + bc.BridgeNotices = true } type umBridgeConfig BridgeConfig diff --git a/example-config.yaml b/example-config.yaml index 825486c..6787e09 100644 --- a/example-config.yaml +++ b/example-config.yaml @@ -177,6 +177,8 @@ bridge: # chat portal rooms. This can be useful if the previous field works fine, # but causes room avatar/name bugs. private_chat_portal_meta: false + # Whether or not Matrix m.notice-type messages should be bridged. + bridge_notices: true # Set this to true to tell the bridge to re-send m.bridge events to all rooms on the next run. # This field will automatically be changed back to false after it, # except if the config file is not writable. diff --git a/portal.go b/portal.go index bd28d28..e77b22f 100644 --- a/portal.go +++ b/portal.go @@ -2029,6 +2029,9 @@ func (portal *Portal) convertMatrixMessage(sender *User, evt *event.Event) (*waP switch content.MsgType { case event.MsgText, event.MsgEmote, event.MsgNotice: text := content.Body + if content.MsgType == event.MsgNotice && !portal.bridge.Config.Bridge.BridgeNotices { + return nil, sender + } if content.Format == event.FormatHTML { text, ctxInfo.MentionedJid = portal.bridge.Formatter.ParseMatrix(content.FormattedBody) }