From 313111a7d886edd3cc05436a2febdbe411cd9fe1 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 2 Aug 2021 11:39:32 -0500 Subject: [PATCH] Set catapult_fwd_timeout on our backend-facing JID 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(-) diff --git a/lib/backend_sgx.rb b/lib/backend_sgx.rb index 85e1b82..30b4513 100644 --- a/lib/backend_sgx.rb +++ b/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 diff --git a/lib/customer.rb b/lib/customer.rb index 7af60af..f779ee6 100644 --- a/lib/customer.rb +++ b/lib/customer.rb @@ -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( diff --git a/lib/registration.rb b/lib/registration.rb index 1634f63..e0950bc 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -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 diff --git a/test/test_registration.rb b/test/test_registration.rb index bdf654e..3b7b906 100644 --- a/test/test_registration.rb +++ b/test/test_registration.rb @@ -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 -- 2.45.2