~singpolyma/sgx-jmp

016d8c4b04f63bc792ab772f841682cb8ebead95 — Stephen Paul Weber 2 years ago 9827b8b
v1 is dead and everyone has been moved
2 files changed, 1 insertions(+), 27 deletions(-)

M lib/bwmsgsv2_repo.rb
M lib/customer_fwd.rb
M lib/bwmsgsv2_repo.rb => lib/bwmsgsv2_repo.rb +1 -11
@@ 50,21 50,11 @@ class Bwmsgsv2Repo
				"catapult_fwd_timeout-#{sgx.from_jid}",
				customer_fwd.timeout.to_i
			)
		]).then do
			set_default_location(tel) if customer_fwd.v2_safe?
		end
		])
	end

protected

	def set_default_location(tel)
		# Migrate location if needed
		BandwidthIris::SipPeer.new(
			site_id: CONFIG[:bandwidth_site],
			id: CONFIG[:bandwidth_peer]
		).move_tns([tel])
	end

	def set_or_delete(k, v)
		if v.nil?
			REDIS.del(k)

M lib/customer_fwd.rb => lib/customer_fwd.rb +0 -16
@@ 57,15 57,7 @@ class CustomerFwd
		BANDWIDTH_VOICE.create_call(account, body: request).data.call_id
	end

	def v2_safe?
		false
	end

	class Tel < CustomerFwd
		def v2_safe?
			true
		end

		def initialize(values)
			super
			raise "Bad tel format: #{uri}" unless uri.match?(/\Atel:\+1\d{10}\Z/)


@@ 77,20 69,12 @@ class CustomerFwd
	end

	class SIP < CustomerFwd
		def v2_safe?
			uri.end_with?(CONFIG[:sip][:realm])
		end

		def to
			uri
		end
	end

	class XMPP < CustomerFwd
		def v2_safe?
			true
		end

		def to
			jid = uri.sub(/^xmpp:/, "")
			"sip:#{ERB::Util.url_encode(jid)}@sip.cheogram.com"