Add config option to disable bridging m.notices

Closes #259
This commit is contained in:
Héctor Ramírez Franco 2021-02-26 16:10:57 +02:00 committed by Tulir Asokan
parent 3d778a5a44
commit 464a7ee765
3 changed files with 7 additions and 0 deletions

View file

@ -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

View file

@ -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.

View file

@ -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)
}