Преглед на файлове

Add separate config option for status broadcast room tag

Tulir Asokan преди 3 години
родител
ревизия
54ad27f644
променени са 4 файла, в които са добавени 12 реда и са изтрити 4 реда
  1. 1 0
      config/bridge.go
  2. 1 0
      config/upgrade.go
  3. 3 1
      example-config.yaml
  4. 7 3
      user.go

+ 1 - 0
config/bridge.go

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

+ 1 - 0
config/upgrade.go

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

+ 3 - 1
example-config.yaml

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

+ 7 - 3
user.go

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