Chore: Cleanup attachment handling for Facebook & Whatsapp (#1051)

* Chore: Enable file upload for facebook messenger
* Chore: Fix attachments
* Chore: Fix Specs
* Fix ReplyBox file attachment logic
* Set default value for message

Co-authored-by: Pranav Raj Sreepuram <pranavrajs@gmail.com>
This commit is contained in:
Sojan Jose
2020-07-17 00:32:32 +05:30
committed by GitHub
parent 196741d975
commit a18d54b706
14 changed files with 212 additions and 108 deletions

View File

@@ -17,19 +17,26 @@ class Facebook::SendOnFacebookService < Base::SendOnChannelService
end
def fb_attachment_message_params
attachment = message.attachments.first
{
recipient: { id: contact.get_source_id(inbox.id) },
message: {
attachment: {
type: 'image',
type: attachment_type(attachment),
payload: {
url: message.attachments.first.file_url
url: attachment.file_url
}
}
}
}
end
def attachment_type(attachment)
return attachment.file_type if %w[image audio video file].include? attachment.file_type
'file'
end
def fb_message_params
if message.attachments.blank?
fb_text_message_params