Class: Stealth::Services::Facebook::MessageHandler
- Inherits:
-
BaseMessageHandler
- Object
- BaseMessageHandler
- Stealth::Services::Facebook::MessageHandler
- Defined in:
- lib/stealth/services/facebook/message_handler.rb
Instance Attribute Summary collapse
-
#facebook_message ⇒ Object
readonly
Returns the value of attribute facebook_message.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#service_message ⇒ Object
readonly
Returns the value of attribute service_message.
Instance Method Summary collapse
- #coordinate ⇒ Object
-
#initialize(params:, headers:) ⇒ MessageHandler
constructor
A new instance of MessageHandler.
- #process ⇒ Object
Constructor Details
#initialize(params:, headers:) ⇒ MessageHandler
Returns a new instance of MessageHandler.
15 16 17 18 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 15 def initialize(params:, headers:) @params = params @headers = headers end |
Instance Attribute Details
#facebook_message ⇒ Object (readonly)
Returns the value of attribute facebook_message.
13 14 15 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 13 def @facebook_message end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
13 14 15 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 13 def headers @headers end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
13 14 15 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 13 def params @params end |
#service_message ⇒ Object (readonly)
Returns the value of attribute service_message.
13 14 15 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 13 def @service_message end |
Instance Method Details
#coordinate ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 20 def coordinate if facebook_is_validating_webhook? respond_with_validation else # Queue the request processing so we can respond quickly to FB # and also keep track of this message Stealth::Services::HandleMessageJob.perform_async('facebook', params, {}) # Relay our acceptance [200, 'OK'] end end |
#process ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 33 def process @service_message = ServiceMessage.new(service: 'facebook') @facebook_message = params['entry'].first['messaging'].first .sender_id = get_sender_id . = process_facebook_event end |