cancel.rb
1# frozen_string_literal: true
2
3class AdminAction
4 class CancelCustomer
5 def self.call(customer, customer_repo:, **)
6 m = Blather::Stanza::Message.new
7 m.from = CONFIG[:notify_from]
8 m.body = "Your JMP account has been cancelled."
9 customer.stanza_to(m).then {
10 EMPromise.all([
11 customer.stanza_to(Blather::Stanza::Iq::IBR.new(:set).tap(&:remove!)),
12 customer.deregister!,
13 customer_repo.disconnect_tel(customer)
14 ])
15 }
16 end
17 end
18end