Skip to content

Commit

Permalink
Add config option to disable bridging m.notices
Browse files Browse the repository at this point in the history
Closes #259
  • Loading branch information
hramirezf authored and tulir committed Feb 26, 2021
1 parent 3d778a5 commit 464a7ee
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -129,6 +130,7 @@ func (bc *BridgeConfig) setDefaults() {

bc.InviteOwnPuppetForBackfilling = true
bc.PrivateChatPortalMeta = false
bc.BridgeNotices = true
}

type umBridgeConfig BridgeConfig
Expand Down
2 changes: 2 additions & 0 deletions example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions portal.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 464a7ee

Please sign in to comment.