summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-05-05 09:37:36 +0200
committerPeter Kozak <spag@golwen.net>2013-05-05 09:37:36 +0200
commit4cd6ef5dc7b98e389ef526db448deaaa611f926e (patch)
tree23e14f5daafadcb39f545eb877c3d9f233260b19 /app/models
parentf70038715ec1ae40fac7177f4ea44e2f9dd5140b (diff)
resolve_prerouting method added
Diffstat (limited to 'app/models')
-rw-r--r--app/models/phone_number.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/app/models/phone_number.rb b/app/models/phone_number.rb
index f6453ce..919b703 100644
--- a/app/models/phone_number.rb
+++ b/app/models/phone_number.rb
@@ -223,6 +223,25 @@ class PhoneNumber < ActiveRecord::Base
end
end
end
+
+ def resolve_prerouting
+ return PhoneNumber.resolve_prerouting(self.number, self.phone_numberable)
+ end
+
+ def self.resolve_prerouting(number, account = SipAccount.first)
+
+ routes = CallRoute.test_route(:prerouting, {
+ 'caller.destination_number' => number,
+ 'caller.auth_account_type' => account.class.name,
+ 'caller.auth_account_id' => account.id,
+ 'caller.auth_account_uuid' => account.try(:uuid),
+ 'caller.account_type' => account.class.name,
+ 'caller.account_id' => account.id,
+ 'caller.account_uuid' => account.try(:uuid),
+ })
+
+ return routes['routes']['1']
+ end
# Find the (grand-)parent tenant of this phone number:
#