M lib/backend_sgx.rb => lib/backend_sgx.rb +4 -0
@@ 33,6 33,10 @@ class BackendSgx
end
end
+ def fwd_timeout=(timeout)
+ REDIS.set("catapult_fwd_timeout-#{from_jid}", timeout)
+ end
+
protected
def from_jid
M lib/customer.rb => lib/customer.rb +1 -1
@@ 48,7 48,7 @@ class Customer
attr_reader :customer_id, :balance
def_delegators :@plan, :active?, :activate_plan_starting_now, :bill_plan,
:currency, :merchant_account, :plan_name
- def_delegators :@sgx, :register!, :registered?
+ def_delegators :@sgx, :register!, :registered?, :fwd_timeout=
def_delegators :@usage, :usage_report, :message_usage, :incr_message_usage
def initialize(
M lib/registration.rb => lib/registration.rb +1 -4
@@ 474,10 474,7 @@ class Registration
@customer.register!(@tel).then {
EMPromise.all([
REDIS.set("catapult_fwd-#{@tel}", cheogram_sip_addr),
- REDIS.set(
- "catapult_fwd_timeout-#{@reply.to.stripped}",
- 25 # ~5 seconds / ring, 5 rings
- )
+ @customer.fwd_timeout = 25 # ~5 seconds / ring, 5 rings
])
}.then { BLATHER << @reply }
end
M test/test_registration.rb => test/test_registration.rb +4 -2
@@ 504,6 504,7 @@ class RegistrationTest < Minitest::Test
class FinishTest < Minitest::Test
Registration::Finish::BLATHER = Minitest::Mock.new
Registration::Finish::REDIS = Minitest::Mock.new
+ BackendSgx::REDIS = Minitest::Mock.new
def setup
@sgx = Minitest::Mock.new(BackendSgx.new("test"))
@@ 563,10 564,10 @@ class RegistrationTest < Minitest::Test
"sip:test%5C40example.com%40cheogram.com@sip.cheogram.com"
]
)
- Registration::Finish::REDIS.expect(
+ BackendSgx::REDIS.expect(
:set,
nil,
- ["catapult_fwd_timeout-test\\40example.com@cheogram.com", 25]
+ ["catapult_fwd_timeout-customer_test@component", 25]
)
Registration::Finish::BLATHER.expect(
:<<,
@@ 584,6 585,7 @@ class RegistrationTest < Minitest::Test
assert_requested create_order
@sgx.verify
Registration::Finish::REDIS.verify
+ BackendSgx::REDIS.verify
Registration::Finish::BLATHER.verify
end
em :test_write