@@ 157,6 157,8 @@ class Registration
class Bitcoin
Payment.kinds[:bitcoin] = method(:new)
+ THIRTY_DAYS = 60 * 60 * 24 * 30
+
def initialize(customer, tel)
@customer = customer
@customer_id = customer.customer_id
@@ 165,20 167,13 @@ class Registration
attr_reader :customer_id, :tel
- def legacy_session_save
- sid = SecureRandom.hex
- REDIS.mset(
- "reg-sid_for-#{customer_id}", sid,
- "reg-session_tel-#{sid}", tel
- )
- end
-
def save
EMPromise.all([
- legacy_session_save,
- REDIS.mset(
- "pending_tel_for-#{customer_id}", tel,
- "pending_plan_for-#{customer_id}", @customer.plan_name
+ REDIS.setex("pending_tel_for-#{@customer.jid}", tel, THIRTY_DAYS),
+ REDIS.setex(
+ "pending_plan_for-#{customer_id}",
+ @customer.plan_name,
+ THIRTY_DAYS
)
])
end
@@ 458,6 453,7 @@ class Registration
def customer_active_tel_purchased
@customer.register!(@tel).catch(&method(:raise_setup_error)).then {
EMPromise.all([
+ REDIS.del("pending_tel_for-#{@customer.jid}"),
REDIS.set("catapult_fwd-#{@tel}", cheogram_sip_addr),
@customer.fwd_timeout = 25 # ~5 seconds / ring, 5 rings
])
@@ 569,6 569,11 @@ class RegistrationTest < Minitest::Test
"sip:test%40example.net@sip.cheogram.com"
]
)
+ Registration::Finish::REDIS.expect(
+ :del,
+ nil,
+ ["pending_tel_for-test@example.net"]
+ )
BackendSgx::REDIS.expect(
:set,
nil,