chore: Allow Facebook channel to receive standby messages (#4511)

This commit is contained in:
Tejaswini Chile 2022-04-28 01:14:03 +05:30 committed by GitHub
parent 8348392d43
commit cb38ec3267
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 11 deletions

View File

@ -54,7 +54,7 @@ class Channel::FacebookPage < ApplicationRecord
response = Facebook::Messenger::Subscriptions.subscribe( response = Facebook::Messenger::Subscriptions.subscribe(
access_token: page_access_token, access_token: page_access_token,
subscribed_fields: %w[ subscribed_fields: %w[
messages message_deliveries message_echoes message_reads messages message_deliveries message_echoes message_reads standby messaging_handovers
] ]
) )
rescue => e rescue => e

View File

@ -3,43 +3,44 @@
class Integrations::Facebook::MessageParser class Integrations::Facebook::MessageParser
def initialize(response_json) def initialize(response_json)
@response = JSON.parse(response_json) @response = JSON.parse(response_json)
@messaging = @response['messaging'] || @response['standby']
end end
def sender_id def sender_id
@response.dig 'messaging', 'sender', 'id' @messaging.dig('sender', 'id')
end end
def recipient_id def recipient_id
@response.dig 'messaging', 'recipient', 'id' @messaging.dig('recipient', 'id')
end end
def time_stamp def time_stamp
@response.dig 'messaging', 'timestamp' @messaging['timestamp']
end end
def content def content
@response.dig 'messaging', 'message', 'text' @messaging.dig('message', 'text')
end end
def sequence def sequence
@response.dig 'messaging', 'message', 'seq' @messaging.dig('message', 'seq')
end end
def attachments def attachments
@response.dig 'messaging', 'message', 'attachments' @messaging.dig('message', 'attachments')
end end
def identifier def identifier
@response.dig 'messaging', 'message', 'mid' @messaging.dig('message', 'mid')
end end
def echo? def echo?
@response.dig 'messaging', 'message', 'is_echo' @messaging.dig('message', 'is_echo')
end end
# TODO : i don't think the payload contains app_id. if not remove # TODO : i don't think the payload contains app_id. if not remove
def app_id def app_id
@response.dig 'messaging', 'message', 'app_id' @messaging.dig('message', 'app_id')
end end
# TODO : does this work ? # TODO : does this work ?

View File

@ -34,7 +34,11 @@ class Integrations::Slack::IncomingMessageBuilder
end end
def supported_message? def supported_message?
SUPPORTED_MESSAGE_TYPES.include?(message[:type]) if message.present? if message.present?
SUPPORTED_MESSAGE_TYPES.include?(message[:type])
else
params[:event][:files].any?
end
end end
def hook_verification? def hook_verification?