Fix. Intercept enterprise ring group.

With enterprise call each outbound channel has its own call_uuid.
But we have to use `intercept` for call_uuid of inbound channel.
This commit is contained in:
Alexey Melnichuk
2015-09-22 19:33:41 +04:00
parent 6010ade8d6
commit e5a0134ec6
4 changed files with 57 additions and 7 deletions
+14 -4
View File
@@ -35,11 +35,19 @@
--add the function
require "resources.functions.explode";
require "resources.functions.trim";
require "resources.functions.channel_utils";
--prepare the api object
api = freeswitch.API();
--connect to the database
require "resources.functions.database_handle";
dbh = database_handle('system');
--get the hostname
hostname = trim(api:execute("switchname", ""));
--check if the session is ready
if ( session:ready() ) then
--answer the session
@@ -163,7 +171,7 @@
--check the database to get the uuid of a ringing call
call_hostname = "";
sql = "SELECT call_uuid AS uuid, hostname, ip_addr FROM channels ";
sql = "SELECT uuid, call_uuid, hostname, ip_addr FROM channels ";
sql = sql .. "WHERE callstate in ('RINGING', 'EARLY') ";
--sql = sql .. "AND direction = 'outbound' ";
sql = sql .. "AND (";
@@ -189,14 +197,16 @@
--for key, val in pairs(row) do
-- freeswitch.consoleLog("NOTICE", "row "..key.." "..val.."\n");
--end
uuid = row.uuid;
if row.uuid == row.call_uuid then
uuid = channel_variable(row.uuid, 'ent_originate_aleg_uuid') or row.uuid
else
uuid = row.call_uuid;
end
call_hostname = row.hostname;
ip_addr = row.ip_addr;
end);
end
--get the hostname
hostname = freeswitch.getGlobalVariable("hostname");
freeswitch.consoleLog("NOTICE", "Hostname:"..hostname.." Call Hostname:"..call_hostname.."\n");
--intercept a call that is ringing