summaryrefslogtreecommitdiff
path: root/misc/freeswitch
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-07 15:58:22 -0500
committerPeter Kozak <spag@golwen.net>2013-03-07 15:58:22 -0500
commitefb96cfaa79b98fa5eb3c2ca704e83af31e77730 (patch)
tree72714e05b2e29d2735b912e72cb2fc4ff0c30b00 /misc/freeswitch
parent2abc9cfb22e55b709a21b041e04a8221f605e9d7 (diff)
voicemail honors destination number
Diffstat (limited to 'misc/freeswitch')
-rw-r--r--misc/freeswitch/scripts/dialplan/dialplan.lua16
-rw-r--r--misc/freeswitch/scripts/dialplan/voicemail.lua9
2 files changed, 14 insertions, 11 deletions
diff --git a/misc/freeswitch/scripts/dialplan/dialplan.lua b/misc/freeswitch/scripts/dialplan/dialplan.lua
index ffad4da..4cc2245 100644
--- a/misc/freeswitch/scripts/dialplan/dialplan.lua
+++ b/misc/freeswitch/scripts/dialplan/dialplan.lua
@@ -579,13 +579,17 @@ end
function Dialplan.voicemail(self, destination)
- if not self.caller.auth_account or self.caller.auth_account.class ~= 'sipaccount' then
- self.log:error('VOICEMAIL - incompatible destination');
- return { continue = false, code = 404, phrase = 'Mailbox not found' }
- end
-
+ require 'common.str';
require 'dialplan.voicemail'
- local voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_sip_account_id(self.caller.auth_account.id);
+
+ local voicemail_account = nil;
+
+ local sip_account_id
+ if not common.str.blank(destination.number) and false then
+ voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_number(destination.number);
+ elseif self.caller.auth_account and self.caller.auth_account.class == 'sipaccount' then
+ voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_sip_account_id(self.caller.auth_account.id);
+ end
if not voicemail_account then
self.log:error('VOICEMAIL - no mailbox');
diff --git a/misc/freeswitch/scripts/dialplan/voicemail.lua b/misc/freeswitch/scripts/dialplan/voicemail.lua
index ae7d0a1..caeeb48 100644
--- a/misc/freeswitch/scripts/dialplan/voicemail.lua
+++ b/misc/freeswitch/scripts/dialplan/voicemail.lua
@@ -66,15 +66,14 @@ function Voicemail.find_by_name(self, account_name)
return voicemail_account
end
--- Find Voicemail account by name
+-- Find Voicemail account by number
function Voicemail.find_by_number(self, phone_number)
local sip_account = nil;
require "common.phone_number"
- local phone_number_class = common.phone_number.PhoneNumber:new{ log = self.log, database = self.database };
- local destination_number_object = phone_number_class:find_by_number(phone_number);
- if destination_number_object and destination_number_object.record.phone_numberable_type == "SipAccount" then
- return Voicemail:find_by_sip_account_id(destination_number_object.record.phone_numberable_id);
+ local destination_number_object = common.phone_number.PhoneNumber:new{ log = self.log, database = self.database }:find_by_number(phone_number);
+ if destination_number_object and destination_number_object.record.phone_numberable_type:lower() == "sipaccount" then
+ return self:find_by_sip_account_id(destination_number_object.record.phone_numberable_id);
end
return false;