M lib/bwmsgsv2_repo.rb => lib/bwmsgsv2_repo.rb +11 -1
@@ 44,11 44,21 @@ class Bwmsgsv2Repo
"catapult_fwd_timeout-#{sgx.from_jid}",
customer_fwd.timeout.to_i
)
- ])
+ ]).then do
+ set_default_location(tel) if customer_fwd.v2_sip?
+ 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 +8 -0
@@ 52,6 52,10 @@ class CustomerFwd
BANDWIDTH_VOICE.create_call(account, body: request).data.call_id
end
+ def v2_sip?
+ false
+ end
+
class Tel < CustomerFwd
def to
uri.sub(/^tel:/, "")
@@ 59,6 63,10 @@ class CustomerFwd
end
class SIP < CustomerFwd
+ def v2_sip?
+ uri.end_with?(CONFIG[:sip][:realm])
+ end
+
def to
uri
end
M sgx_jmp.rb => sgx_jmp.rb +0 -4
@@ 625,10 625,6 @@ Command.new(
reply.command << form
}.then do |fwd|
if ["1", "true"].include?(fwd.form.field("change_fwd")&.value.to_s)
- # Migrate location if needed
- BandwidthIris::SipPeer.new(
- site_id: CONFIG[:bandwidth_site], id: CONFIG[:bandwidth_peer]
- ).move_tns([customer.registered?.phone])
Command.execution.customer_repo.put_fwd(
customer,
customer.fwd.with(uri: sip_account.uri)