summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-05-05 09:53:17 +0200
committerPeter Kozak <spag@golwen.net>2013-05-05 09:53:17 +0200
commit8610dace5d1caa31827d560af4bea1621d871010 (patch)
tree9de651efdfc01a7ded522642a201eaacd6c8851e /app
parent11dc1567646feed73d908d293cd0fcba4c6224bb (diff)
resolve prerouting
Diffstat (limited to 'app')
-rw-r--r--app/models/phone_number.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/models/phone_number.rb b/app/models/phone_number.rb
index 4b22f40..193e4a8 100644
--- a/app/models/phone_number.rb
+++ b/app/models/phone_number.rb
@@ -210,6 +210,10 @@ class PhoneNumber < ActiveRecord::Base
self.central_office_code = nil
self.extension = self.number.to_s.strip
else
+ prerouting = resolve_prerouting
+ if prerouting && !prerouting['destination_number'].blank? && prerouting['type'] == 'phonenumber'
+ self.number = prerouting['destination_number']
+ end
parsed_number = PhoneNumber.parse( self.number )
if parsed_number
self.country_code = parsed_number[:country_code]
@@ -225,10 +229,11 @@ class PhoneNumber < ActiveRecord::Base
end
def resolve_prerouting
- return PhoneNumber.resolve_prerouting(self.number, self.phone_numberable)
+ return PhoneNumber.resolve_prerouting(self.number.strip, self.phone_numberable)
end
- def self.resolve_prerouting(number, account = SipAccount.first)
+ def self.resolve_prerouting(number, account = nil)
+ account = account || SipAccount.first
routes = CallRoute.test_route(:prerouting, {
'caller.destination_number' => number,