From f686bfe2db76dd36c911e8c02e6a99f5f69e90f7 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 29 Aug 2022 14:08:06 -0500 Subject: [PATCH] Allow prev from mail-in registration --- lib/registration.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/registration.rb b/lib/registration.rb index 236bd196670b4ba716513298bcd3532aac051573..3ebfa3783b1bd661fb3abfb94de57e0650e82280 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -399,7 +399,9 @@ class Registration class Mail Payment.kinds[:mail] = method(:new) - def initialize(_customer, _tel, final_message: nil, **) + def initialize(customer, tel, final_message: nil, **) + @customer = customer + @tel = tel @final_message = final_message end @@ -425,9 +427,15 @@ class Registration end def write - Command.finish(status: :canceled) do |reply| + Command.reply { |reply| + reply.allowed_actions = [:prev] + reply.status = :canceled reply.command << form - end + }.then { |iq| + raise "Action not allowed" unless iq.prev? + + Activation.for(@customer, @tel).then(&:write) + } end end end