From 70032d56428a547a17113341bd8f06e3a7c7f410 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 30 Jan 2015 01:32:38 +0000 Subject: [PATCH] Work on intercept.lua to prevent an error with the hostname. --- resources/install/scripts/intercept.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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