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.
17 18 19 20 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 17 def initialize(params:, headers:) @params = params @headers = headers end |
Instance Attribute Details
#facebook_message ⇒ Object (readonly)
Returns the value of attribute facebook_message.
15 16 17 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 15 def @facebook_message end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
15 16 17 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 15 def headers @headers end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
15 16 17 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 15 def params @params end |
#service_message ⇒ Object (readonly)
Returns the value of attribute service_message.
15 16 17 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 15 def @service_message end |
Instance Method Details
#coordinate ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 22 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, headers ) # Relay our acceptance [200, 'OK'] end end |
#process ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/stealth/services/facebook/message_handler.rb', line 39 def process @service_message = ServiceMessage.new(service: 'facebook') @facebook_message = params['entry'].first['messaging'].first .sender_id = get_sender_id .target_id = get_target_id . = process_facebook_event end |