fix: scope external_url override to Instagram DM conversations only (#13982)

Previously, all incoming messages from Facebook channel with
instagram_id had their attachment data_url and thumb_url overridden with
external_url. This caused issues for non-Instagram conversations
originating from Facebook Message where the file URL should be used
instead.

Narrows the override to only apply when the conversation type is
instagram_direct_message, which is the only case where Instagram's CDN
URLs need to be used directly.

Fixes
https://linear.app/chatwoot/issue/CW-6722/videos-are-missing-in-facebook-conversation

---------

Co-authored-by: Muhsin <12408980+muhsin-k@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Pranav
2026-04-02 07:26:23 -07:00
committed by GitHub
parent b9b5a18767
commit 441fe4db11
2 changed files with 86 additions and 6 deletions

View File

@@ -120,7 +120,7 @@ class Attachment < ApplicationRecord
height: file.metadata[:height]
}
metadata[:data_url] = metadata[:thumb_url] = external_url if message.inbox.instagram? && message.incoming?
metadata[:data_url] = metadata[:thumb_url] = external_url if instagram_incoming_message?
metadata
end
@@ -156,6 +156,14 @@ class Attachment < ApplicationRecord
}
end
def instagram_incoming_message?
return false unless message.incoming?
return true if message.inbox.instagram_direct?
message.inbox.instagram? && message.conversation&.additional_attributes&.dig('type') == 'instagram_direct_message'
end
def set_extension
return unless file.attached?
return if extension.present?