diff options
author | Peter Kozak <spag@golwen.net> | 2013-05-05 09:53:48 +0200 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-05-05 09:53:48 +0200 |
commit | 8968171f9cee1e3c4e5a9267484585a8c99c4c43 (patch) | |
tree | a5305b9da4b49bd620b050c7b0b26c5aba5ab5ee | |
parent | 8610dace5d1caa31827d560af4bea1621d871010 (diff) |
resolve_prerouting method added
-rw-r--r-- | app/models/call_forward.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/call_forward.rb b/app/models/call_forward.rb index de3afc4..a4bfbb5 100644 --- a/app/models/call_forward.rb +++ b/app/models/call_forward.rb @@ -56,6 +56,8 @@ class CallForward < ActiveRecord::Base end } + before_validation :resolve_prerouting + after_save :set_presence after_save :deactivate_concurring_entries, :if => Proc.new { |cf| cf.active == true } before_destroy :deactivate_connected_softkeys @@ -135,6 +137,18 @@ class CallForward < ActiveRecord::Base end end + def resolve_prerouting + if self.destinationable_type == 'PhoneNumber' && GsParameter.get('CALLFORWARD_DESTINATION_RESOLVE') != false + if self.call_forwardable.class == PhoneNumber + prerouting = PhoneNumber.resolve_prerouting(self.destination, self.call_forwardable.phone_numberable) + else + prerouting = PhoneNumber.resolve_prerouting(self.destination, self.call_forwardable) + end + if prerouting && !prerouting['destination_number'].blank? && prerouting['type'] == 'phonenumber' + self.destination = prerouting['destination_number'] + end + end + end def send_presence_event(state, call_forwarding_service = nil) dialplan_function = "cftg-#{self.id}" |