forked from mirror/mautrix-discord
Add options to disable or force-enable caching media
This commit is contained in:
parent
9793e00434
commit
cc2d0ae40d
4 changed files with 7 additions and 1 deletions
|
@ -246,7 +246,7 @@ func (br *DiscordBridge) convertLottie(data []byte) ([]byte, string, error) {
|
|||
}
|
||||
|
||||
func (br *DiscordBridge) copyAttachmentToMatrix(intent *appservice.IntentAPI, url string, encrypt bool, meta AttachmentMeta) (returnDBFile *database.File, returnErr error) {
|
||||
isCacheable := !encrypt
|
||||
isCacheable := br.Config.Bridge.CacheMedia != "never" && (br.Config.Bridge.CacheMedia == "always" || !encrypt)
|
||||
returnDBFile = br.DB.File.Get(url, encrypt)
|
||||
if returnDBFile == nil {
|
||||
transferKey := attachmentKey{url, encrypt}
|
||||
|
|
|
@ -52,6 +52,7 @@ type BridgeConfig struct {
|
|||
DeleteGuildOnLeave bool `yaml:"delete_guild_on_leave"`
|
||||
FederateRooms bool `yaml:"federate_rooms"`
|
||||
|
||||
CacheMedia string `yaml:"cache_media"`
|
||||
MediaPatterns MediaPatterns `yaml:"media_patterns"`
|
||||
|
||||
AnimatedSticker struct {
|
||||
|
|
|
@ -56,6 +56,7 @@ func DoUpgrade(helper *up.Helper) {
|
|||
helper.Copy(up.Bool, "bridge", "delete_guild_on_leave")
|
||||
helper.Copy(up.Bool, "bridge", "federate_rooms")
|
||||
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")
|
||||
helper.Copy(up.Str|up.Null, "bridge", "media_patterns", "emojis")
|
||||
helper.Copy(up.Str|up.Null, "bridge", "media_patterns", "stickers")
|
||||
|
|
|
@ -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 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.
|
||||
cache_media: unencrypted
|
||||
# Patterns for converting Discord media to custom mxc:// URIs instead of reuploading.
|
||||
# Each of the patterns can be set to null to disable custom URIs for that type of media.
|
||||
# More details can be found at https://docs.mau.fi/bridges/go/discord/direct-media.html
|
||||
|
|
Loading…
Reference in a new issue