forked from MirrorHub/mautrix-whatsapp
Add option to disable reply fallbacks
This commit is contained in:
parent
a7068cd75b
commit
172ce83318
4 changed files with 9 additions and 1 deletions
|
@ -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"`
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue