lib/backend_sgx.rb 🔗
@@ -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
Stephen Paul Weber created
Not on our inbound-facing JID. This is why we shouldn't be mucking in the SGX's
Redis at all...
lib/backend_sgx.rb | 4 ++++
lib/customer.rb | 2 +-
lib/registration.rb | 5 +----
test/test_registration.rb | 6 ++++--
4 files changed, 10 insertions(+), 7 deletions(-)
@@ -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
@@ -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(
@@ -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
@@ -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