Add separate config option for status broadcast room tag

This commit is contained in:
Tulir Asokan 2022-04-27 12:45:11 +03:00
parent 5aee338561
commit 54ad27f644
4 changed files with 12 additions and 4 deletions

View file

@ -89,6 +89,7 @@ type BridgeConfig struct {
MarkReadOnlyOnCreate bool `yaml:"mark_read_only_on_create"`
EnableStatusBroadcast bool `yaml:"enable_status_broadcast"`
MuteStatusBroadcast bool `yaml:"mute_status_broadcast"`
StatusBroadcastTag string `yaml:"status_broadcast_tag"`
WhatsappThumbnail bool `yaml:"whatsapp_thumbnail"`
AllowUserInvite bool `yaml:"allow_user_invite"`
FederateRooms bool `yaml:"federate_rooms"`

View file

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

View file

@ -263,8 +263,10 @@ bridge:
# 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.
# This is only applied when creating the room, the user can unmute it later.
mute_status_broadcast: true
# Tag to apply to the status broadcast room.
status_broadcast_tag: m.lowpriority
# Should the bridge use thumbnails from WhatsApp?
# They're disabled by default due to very low resolution.
whatsapp_thumbnail: false

10
user.go
View file

@ -835,9 +835,13 @@ func (user *User) syncChatDoublePuppetDetails(portal *Portal, justCreated bool)
return
}
intent := doublePuppet.CustomIntent()
if portal.Key.JID == types.StatusBroadcastJID && 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)
if portal.Key.JID == types.StatusBroadcastJID && justCreated {
if user.bridge.Config.Bridge.MuteStatusBroadcast {
user.updateChatMute(intent, portal, time.Now().Add(365*24*time.Hour))
}
if len(user.bridge.Config.Bridge.StatusBroadcastTag) > 0 {
user.updateChatTag(intent, portal, user.bridge.Config.Bridge.StatusBroadcastTag, true)
}
return
} else if !chat.Found {
return