~singpolyma/sgx-jmp

edd8623f94fcf1b333fedab44dc75d43b561527f — Stephen Paul Weber 1 year, 5 months ago 75652d7
Pass everything from SGX to user, not just <message/>
1 files changed, 5 insertions(+), 4 deletions(-)

M sgx_jmp.rb
M sgx_jmp.rb => sgx_jmp.rb +5 -4
@@ 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