Fix. Allow intercept only outbound calls.

Now it is possible intercept call from local extension to the world.

Fix. intercept channels also in EARLY state.

One of my softphones return 180 Ringing with SDP (no 183 Progress).
And FreeSWITCH shows such channel as `EARLY` not as `RINGING`)
This commit is contained in:
Alexey Melnichuk 2015-08-12 10:09:56 +04:00
parent 81003e35d8
commit ce9e2cc4d1
2 changed files with 9 additions and 5 deletions

View File

@ -120,7 +120,8 @@ if ( session:ready() ) then
--check the database to get the uuid of a ringing call --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 = "select call_uuid as uuid, hostname, callee_num, ip_addr from channels ";
sql = sql .. "where callstate = 'RINGING' "; sql = sql .. "where callstate in ('RINGING', 'EARLY') ";
sql = sql .. "AND direction = 'outbound' ";
if (extension) then if (extension) then
sql = sql .. "and presence_id = '"..extension.."@"..domain_name.."' "; sql = sql .. "and presence_id = '"..extension.."@"..domain_name.."' ";
else else

View File

@ -110,7 +110,7 @@
sql = sql .. "OR number_alias = '"..caller_id_number.."')"; sql = sql .. "OR number_alias = '"..caller_id_number.."')";
status = dbh:query(sql, function(row) status = dbh:query(sql, function(row)
call_group = row.call_group; call_group = row.call_group;
freeswitch.consoleLog("NOTICE", "result "..call_group.."\n"); freeswitch.consoleLog("NOTICE", "[intercept_group] call_group: "..call_group.."\n");
end); end);
call_groups = explode(",", call_group); call_groups = explode(",", call_group);
@ -135,7 +135,9 @@
end end
x = 0; x = 0;
sql = sql .. ") "; sql = sql .. ") ";
freeswitch.consoleLog("NOTICE", "result "..sql.."\n"); if (debug["sql"]) then
freeswitch.consoleLog("NOTICE", "[intercept_group] sql "..sql.."\n");
end
extensions = {} extensions = {}
status = dbh:query(sql, function(row) status = dbh:query(sql, function(row)
local member = row.extension local member = row.extension
@ -162,7 +164,8 @@
--check the database to get the uuid of a ringing call --check the database to get the uuid of a ringing call
call_hostname = ""; call_hostname = "";
sql = "SELECT call_uuid AS uuid, hostname, ip_addr FROM channels "; sql = "SELECT call_uuid AS uuid, hostname, ip_addr FROM channels ";
sql = sql .. "WHERE callstate = 'RINGING' "; sql = sql .. "WHERE callstate in ('RINGING', 'EARLY') ";
sql = sql .. "AND direction = 'outbound' ";
sql = sql .. "AND ("; sql = sql .. "AND (";
x = 0; x = 0;
for key,extension in pairs(extensions) do for key,extension in pairs(extensions) do
@ -180,7 +183,7 @@
--end --end
sql = sql .. "limit 1 "; sql = sql .. "limit 1 ";
if (debug["sql"]) then if (debug["sql"]) then
freeswitch.consoleLog("NOTICE", "sql "..sql.."\n"); freeswitch.consoleLog("NOTICE", "[intercept_group] sql "..sql.."\n");
end end
dbh:query(sql, function(row) dbh:query(sql, function(row)
--for key, val in pairs(row) do --for key, val in pairs(row) do