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:
@@ -95,7 +95,7 @@ class Channel::Telegram < ApplicationRecord
|
||||
when 'file'
|
||||
telegram_attachment[:type] = 'document'
|
||||
end
|
||||
telegram_attachment[:media] = attachment.file_url
|
||||
telegram_attachment[:media] = attachment.download_url
|
||||
telegram_attachments << telegram_attachment
|
||||
end
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ class Channel::Whatsapp < ApplicationRecord
|
||||
def send_attachment_message(phone_number, message)
|
||||
attachment = message.attachments.first
|
||||
type = %w[image audio video].include?(attachment.file_type) ? attachment.file_type : 'document'
|
||||
attachment_url = attachment.file_url
|
||||
attachment_url = attachment.download_url
|
||||
response = HTTParty.post(
|
||||
"#{api_base_path}/messages",
|
||||
headers: api_headers,
|
||||
|
||||
Reference in New Issue
Block a user