Add. Use params in ring_groups/index.lua (#2146)
This commit is contained in:
committed by
FusionPBX
parent
043c01579a
commit
4b26e8d237
@@ -30,8 +30,14 @@
|
|||||||
local log = require "resources.functions.log".ring_group
|
local log = require "resources.functions.log".ring_group
|
||||||
|
|
||||||
--connect to the database
|
--connect to the database
|
||||||
require "resources.functions.database_handle";
|
local Database = require "resources.functions.database";
|
||||||
dbh = database_handle('system');
|
dbh = Database.new('system');
|
||||||
|
|
||||||
|
--include json library
|
||||||
|
local json
|
||||||
|
if (debug["sql"]) then
|
||||||
|
json = require "resources.functions.lunajson"
|
||||||
|
end
|
||||||
|
|
||||||
--include functions
|
--include functions
|
||||||
require "resources.functions.trim";
|
require "resources.functions.trim";
|
||||||
@@ -104,8 +110,9 @@ local log = require "resources.functions.log".ring_group
|
|||||||
ring_group_forward_enabled = "";
|
ring_group_forward_enabled = "";
|
||||||
ring_group_forward_destination = "";
|
ring_group_forward_destination = "";
|
||||||
sql = "SELECT * FROM v_ring_groups ";
|
sql = "SELECT * FROM v_ring_groups ";
|
||||||
sql = sql .. "where ring_group_uuid = '"..ring_group_uuid.."' ";
|
sql = sql .. "where ring_group_uuid = :ring_group_uuid ";
|
||||||
status = dbh:query(sql, function(row)
|
local params = {ring_group_uuid = ring_group_uuid};
|
||||||
|
status = dbh:query(sql, params, function(row)
|
||||||
domain_uuid = row["domain_uuid"];
|
domain_uuid = row["domain_uuid"];
|
||||||
ring_group_name = row["ring_group_name"];
|
ring_group_name = row["ring_group_name"];
|
||||||
ring_group_extension = row["ring_group_extension"];
|
ring_group_extension = row["ring_group_extension"];
|
||||||
@@ -202,19 +209,20 @@ local log = require "resources.functions.log".ring_group
|
|||||||
session:execute("transfer", ring_group_forward_destination.." XML "..context);
|
session:execute("transfer", ring_group_forward_destination.." XML "..context);
|
||||||
else
|
else
|
||||||
--get the strategy of the ring group, if random, we use random() to order the destinations
|
--get the strategy of the ring group, if random, we use random() to order the destinations
|
||||||
sql = [[
|
local sql = [[
|
||||||
SELECT
|
SELECT
|
||||||
r.ring_group_strategy
|
r.ring_group_strategy
|
||||||
FROM
|
FROM
|
||||||
v_ring_groups as r
|
v_ring_groups as r
|
||||||
WHERE
|
WHERE
|
||||||
ring_group_uuid = ']]..ring_group_uuid..[['
|
ring_group_uuid = :ring_group_uuid
|
||||||
AND r.domain_uuid = ']]..domain_uuid..[['
|
AND r.domain_uuid = :domain_uuid
|
||||||
AND r.ring_group_enabled = 'true'
|
AND r.ring_group_enabled = 'true'
|
||||||
]];
|
]];
|
||||||
|
|
||||||
|
local params = {ring_group_uuid = ring_group_uuid, domain_uuid = domain_uuid};
|
||||||
|
|
||||||
assert(dbh:query(sql, function(row)
|
assert(dbh:query(sql, params, function(row)
|
||||||
if (row.ring_group_strategy == "random") then
|
if (row.ring_group_strategy == "random") then
|
||||||
if (database["type"] == "mysql") then
|
if (database["type"] == "mysql") then
|
||||||
sql_order = 'rand()'
|
sql_order = 'rand()'
|
||||||
@@ -236,16 +244,18 @@ local log = require "resources.functions.log".ring_group
|
|||||||
v_ring_groups as r, v_ring_group_destinations as d
|
v_ring_groups as r, v_ring_group_destinations as d
|
||||||
WHERE
|
WHERE
|
||||||
d.ring_group_uuid = r.ring_group_uuid
|
d.ring_group_uuid = r.ring_group_uuid
|
||||||
AND d.ring_group_uuid = ']]..ring_group_uuid..[['
|
AND d.ring_group_uuid = :ring_group_uuid
|
||||||
AND r.domain_uuid = ']]..domain_uuid..[['
|
AND r.domain_uuid = :domain_uuid
|
||||||
AND r.ring_group_enabled = 'true'
|
AND r.ring_group_enabled = 'true'
|
||||||
ORDER BY
|
ORDER BY
|
||||||
]]..sql_order..[[
|
]]..sql_order..[[
|
||||||
]];
|
]];
|
||||||
--freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n");
|
if debug["sql"] then
|
||||||
|
freeswitch.consoleLog("notice", "[ring group] SQL:" .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
|
end
|
||||||
destinations = {};
|
destinations = {};
|
||||||
x = 1;
|
x = 1;
|
||||||
assert(dbh:query(sql, function(row)
|
assert(dbh:query(sql, params, function(row)
|
||||||
if (row.destination_prompt == "1" or row.destination_prompt == "2") then
|
if (row.destination_prompt == "1" or row.destination_prompt == "2") then
|
||||||
prompt = "true";
|
prompt = "true";
|
||||||
end
|
end
|
||||||
@@ -283,25 +293,29 @@ local log = require "resources.functions.log".ring_group
|
|||||||
--get the dialplan data and save it to a table
|
--get the dialplan data and save it to a table
|
||||||
if (external) then
|
if (external) then
|
||||||
sql = [[select * from v_dialplans as d, v_dialplan_details as s
|
sql = [[select * from v_dialplans as d, v_dialplan_details as s
|
||||||
where (d.domain_uuid = ']] .. domain_uuid .. [[' or d.domain_uuid is null)
|
where (d.domain_uuid = :domain_uuid or d.domain_uuid is null)
|
||||||
and d.app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3'
|
and d.app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3'
|
||||||
and d.dialplan_enabled = 'true'
|
and d.dialplan_enabled = 'true'
|
||||||
and d.dialplan_uuid = s.dialplan_uuid
|
and d.dialplan_uuid = s.dialplan_uuid
|
||||||
order by
|
order by
|
||||||
d.dialplan_order asc,
|
d.dialplan_order asc,
|
||||||
d.dialplan_name asc,
|
d.dialplan_name asc,
|
||||||
d.dialplan_uuid asc,
|
d.dialplan_uuid asc,
|
||||||
s.dialplan_detail_group asc,
|
s.dialplan_detail_group asc,
|
||||||
CASE s.dialplan_detail_tag
|
CASE s.dialplan_detail_tag
|
||||||
WHEN 'condition' THEN 1
|
WHEN 'condition' THEN 1
|
||||||
WHEN 'action' THEN 2
|
WHEN 'action' THEN 2
|
||||||
WHEN 'anti-action' THEN 3
|
WHEN 'anti-action' THEN 3
|
||||||
ELSE 100 END,
|
ELSE 100 END,
|
||||||
s.dialplan_detail_order asc ]]
|
s.dialplan_detail_order asc
|
||||||
--freeswitch.consoleLog("notice", "SQL:" .. sql .. "\n");
|
]];
|
||||||
|
params = {domain_uuid = domain_uuid};
|
||||||
|
if debug["sql"] then
|
||||||
|
freeswitch.consoleLog("notice", "[ring group] SQL:" .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
|
end
|
||||||
dialplans = {};
|
dialplans = {};
|
||||||
x = 1;
|
x = 1;
|
||||||
assert(dbh:query(sql, function(row)
|
assert(dbh:query(sql, params, function(row)
|
||||||
dialplans[x] = row;
|
dialplans[x] = row;
|
||||||
x = x + 1;
|
x = x + 1;
|
||||||
end));
|
end));
|
||||||
@@ -628,10 +642,13 @@ local log = require "resources.functions.log".ring_group
|
|||||||
--execute the time out action
|
--execute the time out action
|
||||||
session:execute(ring_group_timeout_app, ring_group_timeout_data);
|
session:execute(ring_group_timeout_app, ring_group_timeout_data);
|
||||||
else
|
else
|
||||||
sql = "SELECT ring_group_timeout_app, ring_group_timeout_data FROM v_ring_groups ";
|
local sql = "SELECT ring_group_timeout_app, ring_group_timeout_data FROM v_ring_groups ";
|
||||||
sql = sql .. "where ring_group_uuid = '"..ring_group_uuid.."' ";
|
sql = sql .. "where ring_group_uuid = :ring_group_uuid";
|
||||||
--freeswitch.consoleLog("notice", "[ring group] SQL:" .. sql .. "\n");
|
local params = {ring_group_uuid = ring_group_uuid};
|
||||||
dbh:query(sql, function(row)
|
if debug["sql"] then
|
||||||
|
freeswitch.consoleLog("notice", "[ring group] SQL:" .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
|
end
|
||||||
|
dbh:query(sql, params, function(row)
|
||||||
--send missed call notification
|
--send missed call notification
|
||||||
missed();
|
missed();
|
||||||
--execute the time out action
|
--execute the time out action
|
||||||
|
|||||||
Reference in New Issue
Block a user