Move to v2 if at all safe

Stephen Paul Weber created

Change summary

lib/bwmsgsv2_repo.rb      |  2 +-
lib/customer_fwd.rb       | 12 ++++++++++--
test/test_registration.rb |  4 ++++
3 files changed, 15 insertions(+), 3 deletions(-)

Detailed changes

lib/bwmsgsv2_repo.rb 🔗

@@ -45,7 +45,7 @@ class Bwmsgsv2Repo
 				customer_fwd.timeout.to_i
 			)
 		]).then do
-			set_default_location(tel) if customer_fwd.v2_sip?
+			set_default_location(tel) if customer_fwd.v2_safe?
 		end
 	end
 

lib/customer_fwd.rb 🔗

@@ -52,18 +52,22 @@ class CustomerFwd
 		BANDWIDTH_VOICE.create_call(account, body: request).data.call_id
 	end
 
-	def v2_sip?
+	def v2_safe?
 		false
 	end
 
 	class Tel < CustomerFwd
+		def v2_safe?
+			true
+		end
+
 		def to
 			uri.sub(/^tel:/, "")
 		end
 	end
 
 	class SIP < CustomerFwd
-		def v2_sip?
+		def v2_safe?
 			uri.end_with?(CONFIG[:sip][:realm])
 		end
 
@@ -73,6 +77,10 @@ class CustomerFwd
 	end
 
 	class XMPP < CustomerFwd
+		def v2_safe?
+			true
+		end
+
 		def to
 			jid = uri.sub(/^xmpp:/, "")
 			"sip:#{ERB::Util.url_encode(jid)}@sip.cheogram.com"

test/test_registration.rb 🔗

@@ -563,6 +563,10 @@ class RegistrationTest < Minitest::Test
 					"Content-Type" => "application/json"
 				}
 			).to_return(status: 201)
+			stub_request(
+				:post,
+				"https://dashboard.bandwidth.com/v1.0/accounts//sites//sippeers//movetns"
+			)
 			Registration::Finish::REDIS.expect(
 				:del,
 				nil,