.rubocop.yml 🔗
@@ -55,6 +55,9 @@ Layout/LineLength:
Exclude:
- Gemfile
+Layout/EndAlignment:
+ EnforcedStyleAlignWith: start_of_line
+
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space
Stephen Paul Weber created
* fwd-cleanup:
Try to classify URI before saving, even if timeout.zero?
v1 is dead and everyone has been moved
Allow finishing adming command
.rubocop.yml | 3 +++
lib/bwmsgsv2_repo.rb | 12 +-----------
lib/customer_fwd.rb | 32 ++++++++++----------------------
3 files changed, 14 insertions(+), 33 deletions(-)
@@ -55,6 +55,9 @@ Layout/LineLength:
Exclude:
- Gemfile
+Layout/EndAlignment:
+ EnforcedStyleAlignWith: start_of_line
+
Layout/SpaceAroundEqualsInParameterDefault:
EnforcedStyle: no_space
@@ -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)
@@ -7,14 +7,18 @@ require "uri"
class CustomerFwd
def self.for(uri:, timeout:)
timeout = Timeout.new(timeout)
- return None.new(uri: uri, timeout: timeout) if !uri || timeout.zero?
- if uri =~ /\Asip:(.*)@sip.cheogram.com\Z/
- uri = "xmpp:#{$1.gsub(/%([0-9A-F]{2})/i) { $1.to_i(16).chr }}"
+ fwd = if uri
+ if uri =~ /\Asip:(.*)@sip.cheogram.com\Z/
+ uri = "xmpp:#{$1.gsub(/%([0-9A-F]{2})/i) { $1.to_i(16).chr }}"
+ end
+
+ URIS.fetch(uri.split(":", 2).first.to_sym) {
+ raise "Unknown forward URI: #{uri}"
+ }.new(uri: uri, timeout: timeout)
end
- URIS.fetch(uri.split(":", 2).first.to_sym) {
- raise "Unknown forward URI: #{uri}"
- }.new(uri: uri, timeout: timeout)
+
+ fwd && !timeout.zero? ? fwd : None.new(uri: uri, timeout: timeout)
end
class Timeout
@@ -57,15 +61,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 +73,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"