diff options
author | Starfall <root@starfall.blue> | 2020-05-10 02:59:07 -0500 |
---|---|---|
committer | Starfall <root@starfall.blue> | 2020-05-10 02:59:07 -0500 |
commit | 77fa1183cc113e3d3d20140e3545443cf6c7f170 (patch) | |
tree | 2ce4e4dd5235999d163350779f18cf74fe1ff0d1 /config/initializers | |
parent | b107e4f771f036b214563764fcd95786f8016ee7 (diff) | |
parent | c6ff4c634caf718adf7280e04909c091d15add1d (diff) |
Merge branch 'glitch'
Diffstat (limited to 'config/initializers')
-rw-r--r-- | config/initializers/chewy.rb | 6 | ||||
-rw-r--r-- | config/initializers/paperclip.rb | 22 |
2 files changed, 25 insertions, 3 deletions
diff --git a/config/initializers/chewy.rb b/config/initializers/chewy.rb index 9ff0dccc1..18d2f18c1 100644 --- a/config/initializers/chewy.rb +++ b/config/initializers/chewy.rb @@ -23,3 +23,9 @@ module Chewy end end end + +# ElasticSearch uses Faraday internally. Faraday interprets the +# http_proxy env variable by default which leads to issues when +# Mastodon is run with hidden services enabled, because +# ElasticSearch is *not* supposed to be accessed through a proxy +Faraday.ignore_env_proxy = true diff --git a/config/initializers/paperclip.rb b/config/initializers/paperclip.rb index 8909678d6..0dd7f8cf8 100644 --- a/config/initializers/paperclip.rb +++ b/config/initializers/paperclip.rb @@ -10,9 +10,25 @@ Paperclip.interpolates :filename do |attachment, style| end end +Paperclip.interpolates :prefix_path do |attachment, style| + if attachment.storage_schema_version >= 1 && attachment.instance.respond_to?(:local?) && !attachment.instance.local? + 'cache' + File::SEPARATOR + else + '' + end +end + +Paperclip.interpolates :prefix_url do |attachment, style| + if attachment.storage_schema_version >= 1 && attachment.instance.respond_to?(:local?) && !attachment.instance.local? + 'cache/' + else + '' + end +end + Paperclip::Attachment.default_options.merge!( use_timestamp: false, - path: ':class/:attachment/:id_partition/:style/:filename', + path: ':prefix_url:class/:attachment/:id_partition/:style/:filename', storage: :fog ) @@ -91,7 +107,7 @@ else Paperclip::Attachment.default_options.merge!( storage: :filesystem, use_timestamp: true, - path: File.join(ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')), ':class', ':attachment', ':id_partition', ':style', ':filename'), - url: ENV.fetch('PAPERCLIP_ROOT_URL', '/system') + '/:class/:attachment/:id_partition/:style/:filename', + path: File.join(ENV.fetch('PAPERCLIP_ROOT_PATH', File.join(':rails_root', 'public', 'system')), ':prefix_path:class', ':attachment', ':id_partition', ':style', ':filename'), + url: ENV.fetch('PAPERCLIP_ROOT_URL', '/system') + '/:prefix_url:class/:attachment/:id_partition/:style/:filename', ) end |