@@ 19,6 19,7 @@ CONFIG =
.new(safe: Dhall::Coder::JSON_LIKE + [Symbol, Proc])
.load(ARGV[0], transform_keys: ->(k) { k&.to_sym })
+Blather::Stanza.handler_list << :stanza
singleton_class.class_eval do
include Blather::DSL
Blather::DSL.append_features(self)
@@ 139,16 140,16 @@ message to: /\Aaccount@/ do |m|
end
end
-message to: /\Acustomer_/, from: /@#{CONFIG[:sgx]}(\/|\Z)/ do |m|
- sentry_hub = new_sentry_hub(m, name: "message_customer")
+stanza to: /\Acustomer_/, from: /@#{CONFIG[:sgx]}(\/|\Z)/ do |s|
+ sentry_hub = new_sentry_hub(s, name: "stanza_customer")
Customer.for_customer_id(
m.to.node.delete_prefix("customer_")
).then { |customer|
sentry_hub.current_scope.set_user(
id: customer.customer_id,
- jid: m.from.stripped.to_s
+ jid: s.from.stripped.to_s
)
- customer.stanza_to(m)
+ customer.stanza_to(s)
}.catch { |e| panic(e, sentry_hub) }
end
@@ 242,29 243,21 @@ end
disco_items node: "http://jabber.org/protocol/commands" do |iq|
reply = iq.reply
reply.items = [
+ { node: "number-display", name: "Display JMP Number" },
+ { node: "configure-calls", name: "Configure Calls" },
# TODO: don't show this item if no braintree methods available
# TODO: don't show this item if no plan for this customer
+ { node: "buy-credit", name: "Buy account credit" },
+ { node: "jabber:iq:register", name: "Register" },
+ { node: "usage", name: "Show Monthly Usage" },
+ { node: "reset sip account", name: "Create or Reset SIP Account" }
+ ].map do |item|
Blather::Stanza::DiscoItems::Item.new(
iq.to,
- "buy-credit",
- "Buy account credit"
- ),
- Blather::Stanza::DiscoItems::Item.new(
- iq.to,
- "jabber:iq:register",
- "Register"
- ),
- Blather::Stanza::DiscoItems::Item.new(
- iq.to,
- "usage",
- "Show Monthly Usage"
- ),
- Blather::Stanza::DiscoItems::Item.new(
- iq.to,
- "reset sip account",
- "Create or Reset SIP Account"
+ item[:node],
+ item[:name]
)
- ]
+ end
self << reply
end
@@ 302,6 295,19 @@ def reply_with_note(iq, text, type: :info)
self << reply
end
+# Commands that just pass through to the SGX
+command node: ["number-display", "configure-calls"] do |iq|
+ sentry_hub = new_sentry_hub(iq, name: iq.node)
+ Customer.for_jid(iq.from.stripped).then { |customer|
+ sentry_hub.current_scope.set_user(
+ id: customer.customer_id,
+ jid: iq.from.stripped.to_s
+ )
+
+ customer.stanza_from(iq)
+ }.catch { |e| panic(e, sentry_hub) }
+end
+
command :execute?, node: "buy-credit", sessionid: nil do |iq|
sentry_hub = new_sentry_hub(iq, name: iq.node)
reply = iq.reply