Эх сурвалжийг харах

Add option to mute the status broadcast room by default

Tulir Asokan 3 жил өмнө
parent
commit
ed58449544

+ 1 - 0
config/bridge.go

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

+ 1 - 0
config/upgrade.go

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

+ 3 - 0
example-config.yaml

@@ -169,6 +169,9 @@ bridge:
     # Should WhatsApp status messages be bridged into a Matrix room?
     # Should WhatsApp status messages be bridged into a Matrix room?
     # Disabling this won't affect already created status broadcast rooms.
     # Disabling this won't affect already created status broadcast rooms.
     enable_status_broadcast: true
     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?
     # Should the bridge use thumbnails from WhatsApp?
     # They're disabled by default due to very low resolution.
     # They're disabled by default due to very low resolution.
     whatsapp_thumbnail: false
     whatsapp_thumbnail: false

+ 6 - 0
user.go

@@ -573,6 +573,12 @@ func (user *User) syncChatDoublePuppetDetails(portal *Portal, justCreated bool)
 			return
 			return
 		}
 		}
 		intent := doublePuppet.CustomIntent()
 		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.updateChatMute(intent, portal, chat.MutedUntil)
 		user.updateChatTag(intent, portal, user.bridge.Config.Bridge.ArchiveTag, chat.Archived)
 		user.updateChatTag(intent, portal, user.bridge.Config.Bridge.ArchiveTag, chat.Archived)
 		user.updateChatTag(intent, portal, user.bridge.Config.Bridge.PinnedTag, chat.Pinned)
 		user.updateChatTag(intent, portal, user.bridge.Config.Bridge.PinnedTag, chat.Pinned)