Add option to disable direct CDN uploads
This commit is contained in:
@@ -51,6 +51,7 @@ type BridgeConfig struct {
|
||||
DeletePortalOnChannelDelete bool `yaml:"delete_portal_on_channel_delete"`
|
||||
DeleteGuildOnLeave bool `yaml:"delete_guild_on_leave"`
|
||||
FederateRooms bool `yaml:"federate_rooms"`
|
||||
UseDiscordCDNUpload bool `yaml:"use_discord_cdn_upload"`
|
||||
|
||||
CacheMedia string `yaml:"cache_media"`
|
||||
MediaPatterns MediaPatterns `yaml:"media_patterns"`
|
||||
|
||||
@@ -55,6 +55,7 @@ func DoUpgrade(helper *up.Helper) {
|
||||
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")
|
||||
helper.Copy(up.Bool, "bridge", "use_discord_cdn_upload")
|
||||
helper.Copy(up.Bool, "bridge", "media_patterns", "enabled")
|
||||
helper.Copy(up.Str, "bridge", "cache_media")
|
||||
helper.Copy(up.Str|up.Null, "bridge", "media_patterns", "attachments")
|
||||
|
||||
@@ -145,6 +145,10 @@ bridge:
|
||||
# Whether or not created rooms should have federation enabled.
|
||||
# If false, created portal rooms will never be federated.
|
||||
federate_rooms: true
|
||||
# Should the bridge upload media to the Discord CDN directly before sending the message when using a user token,
|
||||
# like the official client does? The other option is sending the media in the message send request as a form part
|
||||
# (which is always used by bots and webhooks).
|
||||
use_discord_cdn_upload: true
|
||||
# Should mxc uris copied from Discord be cached?
|
||||
# This can be `never` to never cache, `unencrypted` to only cache unencrypted mxc uris, or `always` to cache everything.
|
||||
# If you have a media repo that generates non-unique mxc uris, you should set this to never.
|
||||
|
||||
@@ -1496,7 +1496,7 @@ func (portal *Portal) handleMatrixMessage(sender *User, evt *event.Event) {
|
||||
sendReq.Content, sendReq.AllowedMentions = portal.parseMatrixHTML(content)
|
||||
}
|
||||
|
||||
if !isWebhookSend && sess.IsUser {
|
||||
if portal.bridge.Config.Bridge.UseDiscordCDNUpload && !isWebhookSend && sess.IsUser {
|
||||
att := &discordgo.MessageAttachment{
|
||||
ID: "0",
|
||||
Filename: filename,
|
||||
|
||||
Reference in New Issue
Block a user