add line image

This commit is contained in:
Muhsin Keloth
2023-11-23 17:30:36 +05:30
parent 2d1f70eb79
commit c5915203fc
2 changed files with 20 additions and 2 deletions
@@ -392,7 +392,8 @@ export default {
this.isAPIInbox ||
this.isAnEmailChannel ||
this.isASmsInbox ||
this.isATelegramChannel
this.isATelegramChannel ||
this.isALineChannel
);
},
replyButtonLabel() {
+18 -1
View File
@@ -6,7 +6,14 @@ class Line::SendOnLineService < Base::SendOnChannelService
end
def perform_reply
response = channel.client.push_message(message.conversation.contact_inbox.source_id, [{ type: 'text', text: message.content }])
byebug
payload = if message.attachment?
build_attachment_payload
else
[{ type: 'text', text: message.content }]
end
response = channel.client.push_message(message.conversation.contact_inbox.source_id, payload)
return if response.blank?
parsed_json = JSON.parse(response.body)
@@ -20,6 +27,16 @@ class Line::SendOnLineService < Base::SendOnChannelService
end
end
def build_attachment_payload
case message.attachment_type
when 'image'
[{ type: 'image', originalContentUrl: message.attachment_url, previewImageUrl: message.attachment_url }]
# Add more cases for other types of attachments like 'video', 'audio', etc.
else
[{ type: 'text', text: "Unsupported attachment type: #{message.attachment_type}" }]
end
end
# https://developers.line.biz/en/reference/messaging-api/#error-responses
def external_error(error)
# Message containing information about the error. See https://developers.line.biz/en/reference/messaging-api/#error-messages