Class: Twilio::Rails::Phone::UnansweredCallOperation

Inherits:
BaseOperation show all
Defined in:
app/operations/twilio/rails/phone/unanswered_call_operation.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/operations/twilio/rails/phone/unanswered_call_operation.rb', line 6

def execute
  if !phone_call.outbound?
    Twilio::Rails.config.logger.tagged(self.class) { |l| l.error("Should never be called on inbound call") }
    halt
  end

  if phone_call.unanswered?
    Twilio::Rails.config.logger.tagged(self.class) { |l| l.warn("Skipping duplicate unanswered call job") }
  else
    phone_call.update!(unanswered: true)
    phone_call.tree.unanswered_call.call(phone_call) if phone_call.tree.unanswered_call
  end
end