Use unroute instead of route to bogus jid

Stephen Paul Weber created

Change summary

lib/registration_repo.rb | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

Detailed changes

lib/registration_repo.rb 🔗

@@ -31,7 +31,7 @@ class RegistrationRepo
 			next { code: 0 } unless creds
 
 			EMPromise.all([
-				setup_endstream_route(*creds, "#{creds.first}@example.com"),
+				remove_endstream_route(*creds),
 				@redis.del("endstream_registration-#{jid.stripped}")
 			]).then { |(status, _)| status }
 		end
@@ -51,4 +51,15 @@ protected
 			).body.dig(:did_route_sms_to_xmpp_response, :did_route_sms_to_xmpp_result)
 		}
 	end
+
+	def remove_endstream_route(tel, username, password)
+		EM.promise_defer {
+			@savon.call(
+				:did_unroute_sms, message: {
+					auth: { username: username, password: password },
+					dID: tel.sub(/\A\+/, "")
+				}
+			).body.dig(:did_unroute_sms_response, :did_unroute_sms_result)
+		}
+	end
 end