~singpolyma/sgx-jmp

e6bdcc9f5ca6879ac600c13f110f3c785eb2b098 — Stephen Paul Weber 2 years ago bff79b5
Shunt call to voicemail on exception
1 files changed, 9 insertions(+), 8 deletions(-)

M web.rb
M web.rb => web.rb +9 -8
@@ 274,7 274,7 @@ class Web < Roda
								customer, params["from"], call_id: params["callId"]
							)
						])
					}.then do |(customer_id, fwd, ca)|
					}.then { |(customer_id, fwd, ca)|
						call = ca.create_call(fwd, CONFIG[:creds][:account]) { |cc|
							cc.from = params["from"]
							cc.application_id = params["applicationId"]


@@ 282,13 282,14 @@ class Web < Roda
							cc.disconnect_url = url inbound_calls_path(:transfer_complete)
						}

						if call
							outbound_transfers[params["callId"]] = call
							render :ring, locals: { duration: 300 }
						else
							render :redirect, locals: { to: inbound_calls_path(:voicemail) }
						end
					end
						next EMPromise.reject(:voicemail) unless call

						outbound_transfers[params["callId"]] = call
						render :ring, locals: { duration: 300 }
					}.catch { |e|
						log_error(e) unless e == :voicemail
						render :redirect, locals: { to: inbound_calls_path(:voicemail) }
					}
				end
			end
		end