Add. Use params in is_local/index.lua (#2122)
* Add. Use params in is_local/index.lua * Fix. syntax error in params table.
This commit is contained in:
parent
1da4785b41
commit
fd2a383394
|
|
@ -29,8 +29,13 @@
|
||||||
outbound_caller_id_number = session:getVariable("outbound_caller_id_number");
|
outbound_caller_id_number = session:getVariable("outbound_caller_id_number");
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
require "resources.functions.database_handle";
|
local Database = require "resources.functions.database";
|
||||||
dbh = database_handle('system');
|
|
||||||
|
--include json library
|
||||||
|
local json
|
||||||
|
if (debug["sql"]) then
|
||||||
|
json = require "resources.functions.lunajson"
|
||||||
|
end
|
||||||
|
|
||||||
--prepare the api object
|
--prepare the api object
|
||||||
api = freeswitch.API();
|
api = freeswitch.API();
|
||||||
|
|
@ -43,13 +48,18 @@
|
||||||
|
|
||||||
--get the destination number
|
--get the destination number
|
||||||
if (cache == "-ERR NOT FOUND") then
|
if (cache == "-ERR NOT FOUND") then
|
||||||
sql = "SELECT destination_number, destination_context "
|
local dbh = Database.new('system');
|
||||||
|
|
||||||
|
local sql = "SELECT destination_number, destination_context "
|
||||||
sql = sql .. "FROM v_destinations "
|
sql = sql .. "FROM v_destinations "
|
||||||
sql = sql .. "WHERE destination_number = '"..destination_number.."' "
|
sql = sql .. "WHERE destination_number = :destination_number "
|
||||||
sql = sql .. "AND destination_type = 'inbound' "
|
sql = sql .. "AND destination_type = 'inbound' "
|
||||||
sql = sql .. "AND destination_enabled = 'true' "
|
sql = sql .. "AND destination_enabled = 'true' "
|
||||||
--freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n");
|
local params = {destination_number = destination_number};
|
||||||
assert(dbh:query(sql, function(row)
|
if (debug["sql"]) then
|
||||||
|
freeswitch.consoleLog("notice", "SQL:" .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||||
|
end
|
||||||
|
dbh:query(sql, params, function(row)
|
||||||
|
|
||||||
--set the outbound caller id
|
--set the outbound caller id
|
||||||
if (outbound_caller_id_name ~= nil) then
|
if (outbound_caller_id_name ~= nil) then
|
||||||
|
|
@ -77,7 +87,8 @@
|
||||||
|
|
||||||
--transfer the call
|
--transfer the call
|
||||||
session:transfer(row.destination_number, "XML", row.destination_context);
|
session:transfer(row.destination_number, "XML", row.destination_context);
|
||||||
end));
|
end);
|
||||||
|
|
||||||
else
|
else
|
||||||
--add the function
|
--add the function
|
||||||
require "resources.functions.explode";
|
require "resources.functions.explode";
|
||||||
|
|
@ -111,4 +122,4 @@
|
||||||
|
|
||||||
--transfer the call
|
--transfer the call
|
||||||
session:transfer(var["destination_number"], "XML", var["destination_context"]);
|
session:transfer(var["destination_number"], "XML", var["destination_context"]);
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue