add line image
This commit is contained in:
@@ -392,7 +392,8 @@ export default {
|
||||
this.isAPIInbox ||
|
||||
this.isAnEmailChannel ||
|
||||
this.isASmsInbox ||
|
||||
this.isATelegramChannel
|
||||
this.isATelegramChannel ||
|
||||
this.isALineChannel
|
||||
);
|
||||
},
|
||||
replyButtonLabel() {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user