summaryrefslogtreecommitdiff
path: root/app/models/phone_number.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/phone_number.rb')
-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:
#