Add option to mute the status broadcast room by default

This commit is contained in:
Tulir Asokan 2021-11-15 14:06:31 +02:00
parent 1f7630cc06
commit ed58449544
4 changed files with 11 additions and 0 deletions

View file

@ -66,6 +66,7 @@ type BridgeConfig struct {
TagOnlyOnCreate bool `yaml:"tag_only_on_create"`
MarkReadOnlyOnCreate bool `yaml:"mark_read_only_on_create"`
EnableStatusBroadcast bool `yaml:"enable_status_broadcast"`
MuteStatusBroadcast bool `yaml:"mute_status_broadcast"`
WhatsappThumbnail bool `yaml:"whatsapp_thumbnail"`
AllowUserInvite bool `yaml:"allow_user_invite"`
FederateRooms bool `yaml:"federate_rooms"`

View file

@ -98,6 +98,7 @@ func (helper *UpgradeHelper) doUpgrade() {
helper.Copy(Str|Null, "bridge", "pinned_tag")
helper.Copy(Bool, "bridge", "tag_only_on_create")
helper.Copy(Bool, "bridge", "enable_status_broadcast")
helper.Copy(Bool, "bridge", "mute_status_broadcast")
helper.Copy(Bool, "bridge", "whatsapp_thumbnail")
helper.Copy(Bool, "bridge", "allow_user_invite")
helper.Copy(Str, "bridge", "command_prefix")

View file

@ -169,6 +169,9 @@ bridge:
# Should WhatsApp status messages be bridged into a Matrix room?
# Disabling this won't affect already created status broadcast rooms.
enable_status_broadcast: true
# Should the status broadcast room be muted and moved into low priority by default?
# This is only applied when creating the room, the user can unmute/untag it later.
mute_status_broadcast: false
# Should the bridge use thumbnails from WhatsApp?
# They're disabled by default due to very low resolution.
whatsapp_thumbnail: false

View file

@ -573,6 +573,12 @@ func (user *User) syncChatDoublePuppetDetails(portal *Portal, justCreated bool)
return
}
intent := doublePuppet.CustomIntent()
if justCreated && user.bridge.Config.Bridge.MuteStatusBroadcast {
user.updateChatMute(intent, portal, time.Now().Add(365 * 24 * time.Hour))
user.updateChatTag(intent, portal, user.bridge.Config.Bridge.ArchiveTag, true)
} else if !chat.Found {
return
}
user.updateChatMute(intent, portal, chat.MutedUntil)
user.updateChatTag(intent, portal, user.bridge.Config.Bridge.ArchiveTag, chat.Archived)
user.updateChatTag(intent, portal, user.bridge.Config.Bridge.PinnedTag, chat.Pinned)