Chore: Provide fixed attachment URLs for Channels (#4507)
Prior to this change, The attachment URL sent from Chatwoot to 3rd party integrations like Whatsapp and Facebook involved a 301 redirect before the original content is served. This causes intermittent breakages for the sent attachments. fixes: #3632 ref: https://blog.saeloun.com/2021/09/14/rails-7-adds-expiring-urls-to-active-storage.html
This commit is contained in:
@@ -44,12 +44,15 @@ class Attachment < ApplicationRecord
|
||||
base_data.merge(file_metadata)
|
||||
end
|
||||
|
||||
# NOTE: the URl returned does a 301 redirect to the actual file
|
||||
def file_url
|
||||
file.attached? ? url_for(file) : ''
|
||||
end
|
||||
|
||||
# NOTE: for External services use this methods since redirect doesn't work effectively in a lot of cases
|
||||
def download_url
|
||||
file.attached? ? rails_storage_proxy_url(file) : ''
|
||||
ActiveStorage::Current.host = Rails.application.routes.default_url_options[:host] if ActiveStorage::Current.host.blank?
|
||||
file.attached? ? file.blob.url : ''
|
||||
end
|
||||
|
||||
def thumb_url
|
||||
|
||||
Reference in New Issue
Block a user