Explorar el Código

Add config option to disable bridging m.notices

Closes #259
Héctor Ramírez Franco hace 4 años
padre
commit
464a7ee765
Se han modificado 3 ficheros con 7 adiciones y 0 borrados
  1. 2 0
      config/bridge.go
  2. 2 0
      example-config.yaml
  3. 3 0
      portal.go

+ 2 - 0
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

+ 2 - 0
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.

+ 3 - 0
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)
 		}