From 5b59db24464111b8acdb694cc9a5b0e21b9992de Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 3 Aug 2022 09:29:07 -0500 Subject: [PATCH] Show FUP before starting registration in earnest --- fup.txt | 1 + lib/registration.rb | 29 +++++++++++++++++++++++++---- test/test_registration.rb | 4 ++-- 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 fup.txt diff --git a/fup.txt b/fup.txt new file mode 100644 index 0000000..83aeea3 --- /dev/null +++ b/fup.txt @@ -0,0 +1 @@ +Note: By continuing to the next step, you agree to JMP's Fair Usage Policy, which our carriers require us to make you aware of: You will not participate in or assist in any fraudulent usage, you acknowledge and agree that SMS messages to or from you may be blocked by carriers or other service providers for reasons known or unknown to JMP, your usage will be consistent with typical human operation, each SMS message will be initiated due to human interaction (as opposed to automated or timed messages), and you acknowledge that JMP reserves the right to take any action necessary for JMP to comply with any applicable CTIA and/or CRTC guidelines. diff --git a/lib/registration.rb b/lib/registration.rb index 816e99c..c03ddea 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -18,7 +18,7 @@ class Registration Registered.new(reg.phone) else tel_selections[customer.jid].then(&:choose_tel).then do |tel| - Activation.for(customer, tel) + FinishOrStartActivation.for(customer, tel) end end end @@ -33,14 +33,35 @@ class Registration end end - class Activation + class FinishOrStartActivation def self.for(customer, tel) - jid = ProxiedJID.new(customer.jid).unproxied if customer.active? Finish.new(customer, tel) elsif customer.balance >= CONFIG[:activation_amount_accept] BillPlan.new(customer, tel) - elsif CONFIG[:approved_domains].key?(jid.domain.to_sym) + else + new(customer, tel) + end + end + + def initialize(customer, tel) + @customer = customer + @tel = tel + end + + def write + Command.reply { |reply| + reply.allowed_actions = [:next] + reply.note_type = :info + reply.note_text = File.read("#{__dir__}/../fup.txt") + }.then { Activation.for(@customer, @tel).write } + end + end + + class Activation + def self.for(customer, tel) + jid = ProxiedJID.new(customer.jid).unproxied + if CONFIG[:approved_domains].key?(jid.domain.to_sym) Allow.for(customer, tel, jid) else new(customer, tel) diff --git a/test/test_registration.rb b/test/test_registration.rb index 8a150e8..dbd2619 100644 --- a/test/test_registration.rb +++ b/test/test_registration.rb @@ -46,7 +46,7 @@ class RegistrationTest < Minitest::Test iq = Blather::Stanza::Iq::Command.new iq.from = "test@approved.example.com" result = execute_command(iq) do - Registration.for( + Registration::Activation.for( customer( sgx: sgx, jid: Blather::JID.new("test\\40approved.example.com@component") @@ -65,7 +65,7 @@ class RegistrationTest < Minitest::Test iq = Blather::Stanza::Iq::Command.new iq.from = "test@example.com" result = execute_command(iq) do - Registration.for( + Registration::Activation.for( customer(sgx: sgx), web_manager ) -- 2.38.5