~singpolyma/sgx-jmp

48e95536b5d82e4939cec4a1ae9883390a7b1ad8 — Stephen Paul Weber 2 years ago 6fa0039
Sentry hotfixes
1 files changed, 3 insertions(+), 14 deletions(-)

M sgx_jmp.rb
M sgx_jmp.rb => sgx_jmp.rb +3 -14
@@ 120,17 120,6 @@ BANDWIDTH_VOICE = Bandwidth::Client.new(
	voice_basic_auth_password: CONFIG[:creds][:password]
).voice_client.client

def new_sentry_hub(stanza, name: nil)
	hub = Sentry.get_current_hub&.new_from_top
	raise "Sentry.init has not been called" unless hub

	hub.push_scope
	hub.current_scope.clear_breadcrumbs
	hub.current_scope.set_transaction_name(name) if name
	hub.current_scope.set_user(jid: stanza.from.stripped.to_s)
	hub
end

class AuthError < StandardError; end

# Braintree is not async, so wrap in EM.defer for now


@@ 286,7 275,7 @@ before(
before nil, to: /\Acustomer_/, from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/ do |s|
	StatsD.increment("stanza_customer")

	Sentry.set_transaction_name("stanza_customer")
	Sentry.get_current_scope.set_transaction_name("stanza_customer")
	CustomerRepo.new(set_user: Sentry.method(:set_user)).find(
		s.to.node.delete_prefix("customer_")
	).then { |customer| customer.stanza_to(s) }


@@ 300,7 289,7 @@ message(
	from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/
) do |m|
	StatsD.increment("inbound_group_text")
	Sentry.set_transaction_name("inbound_group_text")
	Sentry.get_current_scope.set_transaction_name("inbound_group_text")

	address = m.find("ns:addresses", ns: ADDRESSES_NS).first
		&.find("ns:address", ns: ADDRESSES_NS)


@@ 308,7 297,7 @@ message(
	pass unless address

	CustomerRepo
		.new(set_user: sentry_hub.current_scope.method(:set_user))
		.new(set_user: Sentry.method(:set_user))
		.find_by_jid(address["jid"]).then { |customer|
			m.from = m.from.with(domain: CONFIG[:component][:jid])
			m.to = m.to.with(domain: customer.jid.domain)