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(
access_token: page_access_token,
subscribed_fields: %w[
messages message_deliveries message_echoes message_reads
messages message_deliveries message_echoes message_reads standby messaging_handovers
]
)
rescue => e

View file

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

View file

@ -34,7 +34,11 @@ class Integrations::Slack::IncomingMessageBuilder
end
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
def hook_verification?