Show FUP before starting registration in earnest

Stephen Paul Weber created

Change summary

fup.txt                   |  1 +
lib/registration.rb       | 29 +++++++++++++++++++++++++----
test/test_registration.rb |  4 ++--
3 files changed, 28 insertions(+), 6 deletions(-)

Detailed changes

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.

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)

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
 			)