10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/operations/twilio/rails/phone/twiml/timeout_operation.rb', line 10
def execute
return Twilio::Rails::Phone::Twiml::ErrorOperation.call(phone_call_id: phone_call.id, tree: tree) if phone_call.answering_machine?
response = phone_call.responses.find(response_id)
response.timeout = true
response.save!
if final_timeout?(response, count: tree.config[:final_timeout_attempts])
twiml_response = Twilio::TwiML::VoiceResponse.new do |twiml|
add_messages(twiml, message_set: tree.config[:final_timeout_message], response: response)
twiml.hangup
end
Twilio::Rails.config.logger.info("final timeout on phone_call##{ phone_call.id }")
Twilio::Rails.config.logger.info("timeout_twiml: #{twiml_response.to_s}")
twiml_response.to_s
else
prompt = tree.prompts[response.prompt_handle]
raise Twilio::Rails::Phone::InvalidTreeError, "cannot find #{ response.prompt_handle } in #{ tree.name }" unless prompt
after = prompt.after
after = Twilio::Rails::Phone::Tree::After.new(after.proc.call(response)) if after.proc
Twilio::Rails::Phone::Twiml::AfterOperation.call(phone_call_id: phone_call.id, tree: tree, after: after)
end
end
|