Ver código fonte

Add option to disable reply fallbacks

Tulir Asokan 2 anos atrás
pai
commit
172ce83318
4 arquivos alterados com 9 adições e 1 exclusões
  1. 1 0
      config/bridge.go
  2. 1 0
      config/upgrade.go
  3. 3 0
      example-config.yaml
  4. 4 1
      portal.go

+ 1 - 0
config/bridge.go

@@ -118,6 +118,7 @@ type BridgeConfig struct {
 	CaptionInMessage      bool   `yaml:"caption_in_message"`
 	ExtEvPolls            bool   `yaml:"extev_polls"`
 	CrossRoomReplies      bool   `yaml:"cross_room_replies"`
+	DisableReplyFallbacks bool   `yaml:"disable_reply_fallbacks"`
 
 	MessageHandlingTimeout struct {
 		ErrorAfterStr string `yaml:"error_after"`

+ 1 - 0
config/upgrade.go

@@ -115,6 +115,7 @@ func DoUpgrade(helper *up.Helper) {
 		helper.Copy(up.Bool, "bridge", "extev_polls")
 	}
 	helper.Copy(up.Bool, "bridge", "cross_room_replies")
+	helper.Copy(up.Bool, "bridge", "disable_reply_fallbacks")
 	helper.Copy(up.Str|up.Null, "bridge", "message_handling_timeout", "error_after")
 	helper.Copy(up.Str|up.Null, "bridge", "message_handling_timeout", "deadline")
 

+ 3 - 0
example-config.yaml

@@ -313,6 +313,9 @@ bridge:
     extev_polls: false
     # Should cross-chat replies from WhatsApp be bridged? Most servers and clients don't support this.
     cross_room_replies: false
+    # Disable generating reply fallbacks? Some extremely bad clients still rely on them,
+    # but they're being phased out and will be completely removed in the future.
+    disable_reply_fallbacks: false
     # Maximum time for handling Matrix events. Duration strings formatted for https://pkg.go.dev/time#ParseDuration
     # Null means there's no enforced timeout.
     message_handling_timeout:

+ 4 - 1
portal.go

@@ -1912,10 +1912,13 @@ func (portal *Portal) SetReply(content *event.MessageEventContent, replyTo *Repl
 		}
 		return false
 	}
+	content.RelatesTo = (&event.RelatesTo{}).SetReplyTo(message.MXID)
+	if portal.bridge.Config.Bridge.DisableReplyFallbacks {
+		return true
+	}
 	evt, err := targetPortal.MainIntent().GetEvent(targetPortal.MXID, message.MXID)
 	if err != nil {
 		portal.log.Warnln("Failed to get reply target:", err)
-		content.RelatesTo = (&event.RelatesTo{}).SetReplyTo(message.MXID)
 		return true
 	}
 	_ = evt.Content.ParseRaw(evt.Type)