~singpolyma/sgx-jmp

39741b70f91008e1fd895767d29d1b4ef5aa0058 — Stephen Paul Weber 9 months ago a58d09c
On SGX register! failure, return a useful error to user
1 files changed, 13 insertions(+), 1 deletions(-)

M lib/registration.rb
M lib/registration.rb => lib/registration.rb +13 -1
@@ 7,6 7,7 @@ require "securerandom"
require_relative "./alt_top_up_form"
require_relative "./bandwidth_tn_order"
require_relative "./em"
require_relative "./error_to_send"
require_relative "./oob"
require_relative "./web_register_manager"



@@ 471,8 472,19 @@ class Registration
			"sip:#{ERB::Util.url_encode(@reply.to.stripped.to_s)}@sip.cheogram.com"
		end

		def raise_setup_error
			@reply.note_type = :error
			@reply.note_text =
				"There was an error setting up your number, " \
				"please contact JMP support."
			raise ErrorToSend, @reply
		end

		def customer_active_tel_purchased
			@customer.register!(@tel).then {
			@customer.register!(@tel).catch { |e|
				puts e
				raise_setup_error
			}.then {
				EMPromise.all([
					REDIS.set("catapult_fwd-#{@tel}", cheogram_sip_addr),
					@customer.fwd_timeout = 25 # ~5 seconds / ring, 5 rings