~singpolyma/sgx-jmp

25064310b8dda5683e7aa36ea66e4edffc1ec7b4 — Stephen Paul Weber 1 year, 5 months ago edd8623
Pass through commands we know the SGX can handle
1 files changed, 15 insertions(+), 0 deletions(-)

M sgx_jmp.rb
M sgx_jmp.rb => sgx_jmp.rb +15 -0
@@ 243,6 243,8 @@ 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" },


@@ 293,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