diff --git a/resources/install/scripts/intercept.lua b/resources/install/scripts/intercept.lua index 05a96a079d..a5e1333194 100644 --- a/resources/install/scripts/intercept.lua +++ b/resources/install/scripts/intercept.lua @@ -45,6 +45,12 @@ dbh = database_handle('switch'); end +--prepare the api object + api = freeswitch.API(); + +--add the function + dofile(scripts_dir.."/resources/functions/trim.lua"); + --exits the script if we didn't connect properly assert(dbh:connected()); @@ -109,6 +115,11 @@ if ( session:ready() ) then end end + --predefined variables + uuid = ''; + call_hostname = ''; + callee_num = ''; + --check the database to get the uuid of a ringing call sql = "select call_uuid as uuid, hostname, callee_num, ip_addr from channels "; sql = sql .. "where callstate = 'RINGING' "; @@ -129,12 +140,11 @@ if ( session:ready() ) then uuid = result.uuid; call_hostname = result.hostname; callee_num = result.callee_num; - ip_addr = result.ip_addr; end); end --get the hostname - hostname = freeswitch.getGlobalVariable("hostname"); + hostname = trim(api:execute("hostname", "")); freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n"); --intercept a call that is ringing