Kaynağa Gözat

Add option to disable custom emoji reactions

Tulir Asokan 2 yıl önce
ebeveyn
işleme
09a94010d8
4 değiştirilmiş dosya ile 9 ekleme ve 0 silme
  1. 1 0
      config/bridge.go
  2. 1 0
      config/upgrade.go
  3. 3 0
      example-config.yaml
  4. 4 0
      portal.go

+ 1 - 0
config/bridge.go

@@ -45,6 +45,7 @@ type BridgeConfig struct {
 	MuteChannelsOnCreate        bool `yaml:"mute_channels_on_create"`
 	SyncDirectChatList          bool `yaml:"sync_direct_chat_list"`
 	ResendBridgeInfo            bool `yaml:"resend_bridge_info"`
+	CustomEmojiReactions        bool `yaml:"custom_emoji_reactions"`
 	DeletePortalOnChannelDelete bool `yaml:"delete_portal_on_channel_delete"`
 	DeleteGuildOnLeave          bool `yaml:"delete_guild_on_leave"`
 	FederateRooms               bool `yaml:"federate_rooms"`

+ 1 - 0
config/upgrade.go

@@ -40,6 +40,7 @@ func DoUpgrade(helper *up.Helper) {
 	helper.Copy(up.Bool, "bridge", "mute_channels_on_create")
 	helper.Copy(up.Bool, "bridge", "sync_direct_chat_list")
 	helper.Copy(up.Bool, "bridge", "resend_bridge_info")
+	helper.Copy(up.Bool, "bridge", "custom_emoji_reactions")
 	helper.Copy(up.Bool, "bridge", "delete_portal_on_channel_delete")
 	helper.Copy(up.Bool, "bridge", "delete_guild_on_leave")
 	helper.Copy(up.Bool, "bridge", "federate_rooms")

+ 3 - 0
example-config.yaml

@@ -125,6 +125,9 @@ bridge:
     # 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.
     resend_bridge_info: false
+    # Should incoming custom emoji reactions be bridged as mxc:// URIs?
+    # If set to false, custom emoji reactions will be bridged as the shortcode instead, and the image won't be available.
+    custom_emoji_reactions: true
     # Should the bridge attempt to completely delete portal rooms when a channel is deleted on Discord?
     # If true, the bridge will try to kick Matrix users from the room. Otherwise, the bridge only makes ghosts leave.
     delete_portal_on_channel_delete: false

+ 4 - 0
portal.go

@@ -1522,6 +1522,10 @@ func (portal *Portal) handleDiscordReaction(user *User, reaction *discordgo.Mess
 		extraContent["fi.mau.discord.reaction"] = map[string]any{
 			"id":   reaction.Emoji.ID,
 			"name": reaction.Emoji.Name,
+			"mxc":  matrixReaction,
+		}
+		if !portal.bridge.Config.Bridge.CustomEmojiReactions {
+			content.RelatesTo.Key = fmt.Sprintf(":%s:", reaction.Emoji.Name)
 		}
 	}