summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/dialplan
diff options
context:
space:
mode:
authorPeter Kozak <spag@golwen.net>2013-03-26 15:53:56 +0100
committerPeter Kozak <spag@golwen.net>2013-03-26 15:53:56 +0100
commitecfea29b48d9581725bd6d8a8eb25b090f25b55e (patch)
tree451d0ebd37a0042e1d8f3534d8343c033ba8db90 /misc/freeswitch/scripts/dialplan
parentd79da64a619f83e06990c372dd1f2787b3109e7a (diff)
voicemail_check dialplan function
Diffstat (limited to 'misc/freeswitch/scripts/dialplan')
-rw-r--r--misc/freeswitch/scripts/dialplan/functions.lua25
1 files changed, 11 insertions, 14 deletions
diff --git a/misc/freeswitch/scripts/dialplan/functions.lua b/misc/freeswitch/scripts/dialplan/functions.lua
index a47d9d3..6399c5e 100644
--- a/misc/freeswitch/scripts/dialplan/functions.lua
+++ b/misc/freeswitch/scripts/dialplan/functions.lua
@@ -756,31 +756,28 @@ function Functions.voicemail_message_leave(self, caller, phone_number)
end
-function Functions.voicemail_check(self, caller, phone_number)
+function Functions.voicemail_check(self, caller, number)
+ require 'dialplan.voicemail';
local voicemail_account = nil;
local voicemail_authorized = false;
-
- require 'dialplan.voicemail'
-
- if phone_number then
- voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_number(phone_number);
- else
- if caller.auth_account_type == 'SipAccount' then
- voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_sip_account_id(caller.auth_account.id);
- voicemail_authorized = true;
- end
+
+ if number then
+ voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_number(number);
+ elseif caller.auth_account and tostring(caller.auth_account.class):lower() == 'sipaccount' then
+ voicemail_account = dialplan.voicemail.Voicemail:new{ log = self.log, database = self.database }:find_by_sip_account_id(caller.auth_account.id);
+ voicemail_authorized = true;
end
if not voicemail_account then
+ self.log:notice('FUNCTION_VOICEMAIL_CHECK - mailbox not found');
return { continue = false, code = 404, phrase = 'Mailbox not found', no_cdr = true }
end
- voicemail_account:menu(caller, voicemail_authorized);
-
- return { continue = false, code = 200, phrase = 'OK', no_cdr = true }
+ return voicemail_account:menu_main(caller, voicemail_authorized);
end
+
function Functions.acd_membership_toggle(self, caller, agent_id, phone_number)
-- Find caller's SipAccount
local caller_sip_account = self:ensure_caller_sip_account(caller);