From 4442339c7a9f709b54414806f95870499a1f2941 Mon Sep 17 00:00:00 2001 From: Phillip Davis Date: Tue, 25 Mar 2025 11:56:04 -0400 Subject: [PATCH] notify chatwoot on port-in req --- sgx_jmp.rb | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/sgx_jmp.rb b/sgx_jmp.rb index cd2bb1290a56e3eeaf293c757e3826601eab4de6..5d035911b1353d518180800166a4ec19372f7567 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -838,29 +838,33 @@ Command.new( Command.new( "lnp", "#️⃣ Port in your number from another carrier", - list_for: ->(**) { true } + list_for: ->(**) { true }, + customer_repo: CustomerRepo.new( + sgx_repo: TrivialBackendSgxRepo.new(jid: notify_to) + ) ) { - EMPromise.all([ - Command.customer, - Command.reply do |reply| + Command.customer.then do |customer| + Command.reply { |reply| reply.allowed_actions = [:next] reply.command << FormTemplate.render("lnp") + }.then { |iq| + PortInOrder.parse(customer, iq.form).complete_with do |form| + Command.reply { |reply| + reply.allowed_actions = [:next] + reply.command << form + }.then(&:form) + end + }.then do |order| + order_id = BandwidthIris::PortIn.create(order.to_h)[:order_id] + customer.stanza_from(Blather::Stanza::Message.new( + "", + order.message(order_id) + )) + Command.finish( + "Your port-in request has been accepted, " \ + "support will contact you with next steps" + ) end - ]).then { |(customer, iq)| - PortInOrder.parse(customer, iq.form).complete_with do |form| - Command.reply { |reply| - reply.allowed_actions = [:next] - reply.command << form - }.then(&:form) - end - }.then do |order| - order_id = BandwidthIris::PortIn.create(order.to_h)[:order_id] - BLATHER.join(CONFIG[:notify_admin], "sgx-jmp") - BLATHER.say(CONFIG[:notify_admin], order.message(order_id), :groupchat) - Command.finish( - "Your port-in request has been accepted, " \ - "support will contact you with next steps" - ) end }.register(self).then(&CommandList.method(:register))