Update eavesdrop.lua
Make sure that domain_uuid is set for eavesdrop.lua and update the indentation, comments and use session:ready to prevent errors.
This commit is contained in:
parent
aff5198bd5
commit
516f808949
|
|
@ -16,16 +16,18 @@
|
||||||
--
|
--
|
||||||
-- The Initial Developer of the Original Code is
|
-- The Initial Developer of the Original Code is
|
||||||
-- Mark J Crane <markjcrane@fusionpbx.com>
|
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
-- Copyright (C) 2010
|
-- Copyright (C) 2010-2016
|
||||||
-- the Initial Developer. All Rights Reserved.
|
-- the Initial Developer. All Rights Reserved.
|
||||||
--
|
--
|
||||||
-- Contributor(s):
|
-- Contributor(s):
|
||||||
-- Mark J Crane <markjcrane@fusionpbx.com>
|
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
|
|
||||||
max_tries = "3";
|
--set defaults
|
||||||
digit_timeout = "5000";
|
max_tries = "3";
|
||||||
|
digit_timeout = "5000";
|
||||||
|
|
||||||
extension = argv[1];
|
--get the params
|
||||||
|
extension = argv[1];
|
||||||
|
|
||||||
--include config.lua
|
--include config.lua
|
||||||
require "resources.functions.config";
|
require "resources.functions.config";
|
||||||
|
|
@ -47,34 +49,49 @@ extension = argv[1];
|
||||||
--exits the script if we didn't connect properly
|
--exits the script if we didn't connect properly
|
||||||
assert(dbh:connected());
|
assert(dbh:connected());
|
||||||
|
|
||||||
if ( session:ready() ) then
|
--answer the call
|
||||||
session:answer( );
|
if (session:ready()) then
|
||||||
pin_number = session:getVariable("pin_number");
|
session:answer();
|
||||||
sounds_dir = session:getVariable("sounds_dir");
|
end
|
||||||
domain_name = session:getVariable("domain_name");
|
|
||||||
|
|
||||||
--set the sounds path for the language, dialect and voice
|
--get session variables
|
||||||
|
if (session:ready()) then
|
||||||
|
pin_number = session:getVariable("pin_number");
|
||||||
|
sounds_dir = session:getVariable("sounds_dir");
|
||||||
|
domain_name = session:getVariable("domain_name");
|
||||||
|
end
|
||||||
|
|
||||||
|
--get the domain from sip_from_host
|
||||||
|
if (session:ready() and domain_name == nil) then
|
||||||
|
domain_name = session:getVariable("sip_auth_realm");
|
||||||
|
end
|
||||||
|
|
||||||
|
--set the sounds path for the language, dialect and voice
|
||||||
|
if (session:ready()) then
|
||||||
default_language = session:getVariable("default_language");
|
default_language = session:getVariable("default_language");
|
||||||
default_dialect = session:getVariable("default_dialect");
|
default_dialect = session:getVariable("default_dialect");
|
||||||
default_voice = session:getVariable("default_voice");
|
default_voice = session:getVariable("default_voice");
|
||||||
if (not default_language) then default_language = 'en'; end
|
if (not default_language) then default_language = 'en'; end
|
||||||
if (not default_dialect) then default_dialect = 'us'; end
|
if (not default_dialect) then default_dialect = 'us'; end
|
||||||
if (not default_voice) then default_voice = 'callie'; end
|
if (not default_voice) then default_voice = 'callie'; end
|
||||||
|
end
|
||||||
|
|
||||||
--set defaults
|
--set defaults
|
||||||
if (digit_min_length) then
|
if (digit_min_length) then
|
||||||
--do nothing
|
--do nothing
|
||||||
else
|
else
|
||||||
digit_min_length = "2";
|
digit_min_length = "2";
|
||||||
end
|
end
|
||||||
|
|
||||||
if (digit_max_length) then
|
if (digit_max_length) then
|
||||||
--do nothing
|
--do nothing
|
||||||
else
|
else
|
||||||
digit_max_length = "11";
|
digit_max_length = "11";
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--session:execute('info');
|
||||||
--if the pin number is provided then require it
|
--if the pin number is provided then require it
|
||||||
|
if (session:ready()) then
|
||||||
if (pin_number) then
|
if (pin_number) then
|
||||||
min_digits = string.len(pin_number);
|
min_digits = string.len(pin_number);
|
||||||
max_digits = string.len(pin_number)+1;
|
max_digits = string.len(pin_number)+1;
|
||||||
|
|
@ -89,22 +106,22 @@ if ( session:ready() ) then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--check the database to get the uuid
|
--check the database to get the uuid to eavesdrop on
|
||||||
--eavesdrop
|
if (session:ready()) then
|
||||||
sql = "select uuid from channels where presence_id = '"..extension.."@"..domain_name.."' ";
|
sql = "select uuid from channels where presence_id = '"..extension.."@"..domain_name.."' ";
|
||||||
freeswitch.consoleLog("NOTICE", "[eavesdrop] sql "..sql.."\n");
|
freeswitch.consoleLog("NOTICE", "[eavesdrop] sql "..sql.."\n");
|
||||||
dbh:query(sql, function(result)
|
dbh:query(sql, function(result)
|
||||||
for key, val in pairs(result) do
|
for key, val in pairs(result) do
|
||||||
freeswitch.consoleLog("NOTICE", "[eavesdrop] result "..key.." "..val.."\n");
|
freeswitch.consoleLog("NOTICE", "[eavesdrop] result "..key.." "..val.."\n");
|
||||||
end
|
end
|
||||||
uuid = result.uuid;
|
uuid = result.uuid;
|
||||||
end);
|
end);
|
||||||
|
end
|
||||||
end
|
|
||||||
|
|
||||||
--eavesdrop
|
--eavesdrop
|
||||||
if (uuid) then
|
if (session:ready() and uuid) then
|
||||||
session:execute("eavesdrop", uuid); --call barge
|
session:execute("eavesdrop", uuid); --call barge
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue