Add. Use params in ring_groups/destination.lua (#2163)
This commit is contained in:
committed by
FusionPBX
parent
915c5dea48
commit
28b04d9200
@@ -27,9 +27,15 @@
|
|||||||
require "resources.functions.config";
|
require "resources.functions.config";
|
||||||
|
|
||||||
--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_handle('system');
|
||||||
|
|
||||||
|
--include json library
|
||||||
|
local json
|
||||||
|
if (debug["sql"]) then
|
||||||
|
json = require "resources.functions.lunajson"
|
||||||
|
end
|
||||||
|
|
||||||
--set default variables
|
--set default variables
|
||||||
sounds_dir = "";
|
sounds_dir = "";
|
||||||
recordings_dir = "";
|
recordings_dir = "";
|
||||||
@@ -105,17 +111,19 @@
|
|||||||
freeswitch.consoleLog("NOTICE", "[ring_group] menu_selection: "..menu_selection.."\n");
|
freeswitch.consoleLog("NOTICE", "[ring_group] menu_selection: "..menu_selection.."\n");
|
||||||
if (menu_selection == "1") then
|
if (menu_selection == "1") then
|
||||||
--first, check to see if the destination is already in this ring group
|
--first, check to see if the destination is already in this ring group
|
||||||
sql = [[
|
local sql = [[
|
||||||
SELECT COUNT(*) AS in_group FROM
|
SELECT COUNT(*) AS in_group FROM
|
||||||
v_ring_group_destinations
|
v_ring_group_destinations
|
||||||
WHERE
|
WHERE
|
||||||
domain_uuid = ']]..domain_uuid..[['
|
domain_uuid = :domain_uuid
|
||||||
AND ring_group_uuid = ']]..ring_group_uuid..[['
|
AND ring_group_uuid = :ring_group_uuid
|
||||||
AND destination_number = ']]..destination..[['
|
AND destination_number = :destination
|
||||||
]];
|
]];
|
||||||
--freeswitch.consoleLog("NOTICE", "[ring_group] SQL "..sql.."\n");
|
local params = {domain_uuid = domain_uuid, ring_group_uuid = ring_group_uuid,
|
||||||
|
destination = destination};
|
||||||
|
--freeswitch.consoleLog("NOTICE", "[ring_group] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||||
|
|
||||||
assert(dbh:query(sql, function(row)
|
assert(dbh:query(sql, params, function(row)
|
||||||
if (row.in_group == "0") then
|
if (row.in_group == "0") then
|
||||||
sql = [[
|
sql = [[
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
@@ -128,15 +136,26 @@
|
|||||||
destination_timeout
|
destination_timeout
|
||||||
)
|
)
|
||||||
VALUES
|
VALUES
|
||||||
( ']]..ring_group_destination_uuid..[[',
|
( :ring_group_destination_uuid,
|
||||||
']]..domain_uuid..[[',
|
:domain_uuid,
|
||||||
']]..ring_group_uuid..[[',
|
:ring_group_uuid,
|
||||||
']]..destination..[[',
|
:destination,
|
||||||
]]..destination_delay..[[,
|
:destination_delay,
|
||||||
]]..destination_timeout..[[
|
:destination_timeout
|
||||||
)]];
|
)]];
|
||||||
freeswitch.consoleLog("NOTICE", "[ring_group][destination] SQL "..sql.."\n");
|
|
||||||
dbh:query(sql);
|
params = {
|
||||||
|
ring_group_destination_uuid = ring_group_destination_uuid;
|
||||||
|
domain_uuid = domain_uuid;
|
||||||
|
ring_group_uuid = ring_group_uuid;
|
||||||
|
destination = destination;
|
||||||
|
destination_delay = destination_delay;
|
||||||
|
destination_timeout = destination_timeout;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
freeswitch.consoleLog("NOTICE", "[ring_group][destination] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||||
|
dbh:query(sql, params);
|
||||||
|
|
||||||
freeswitch.consoleLog("NOTICE", "[ring_group][destination] LOG IN\n");
|
freeswitch.consoleLog("NOTICE", "[ring_group][destination] LOG IN\n");
|
||||||
session:streamFile("ivr/ivr-you_are_now_logged_in.wav");
|
session:streamFile("ivr/ivr-you_are_now_logged_in.wav");
|
||||||
@@ -147,16 +166,18 @@
|
|||||||
end));
|
end));
|
||||||
end
|
end
|
||||||
if (menu_selection == "2") then
|
if (menu_selection == "2") then
|
||||||
sql = [[
|
local sql = [[
|
||||||
DELETE FROM
|
DELETE FROM
|
||||||
v_ring_group_destinations
|
v_ring_group_destinations
|
||||||
WHERE
|
WHERE
|
||||||
domain_uuid =']]..domain_uuid..[['
|
domain_uuid =:domain_uuid
|
||||||
AND ring_group_uuid=']]..ring_group_uuid..[['
|
AND ring_group_uuid=:ring_group_uuid
|
||||||
AND destination_number=']]..destination..[['
|
AND destination_number=:destination
|
||||||
]];
|
]];
|
||||||
freeswitch.consoleLog("NOTICE", "[ring_group][destination] SQL "..sql.."\n");
|
local params = {domain_uuid = domain_uuid, ring_group_uuid = ring_group_uuid,
|
||||||
dbh:query(sql);
|
destination = destination};
|
||||||
|
freeswitch.consoleLog("NOTICE", "[ring_group][destination] SQL: " .. sql .. "; params: " .. json.encode(params) .. "\n");
|
||||||
|
dbh:query(sql, params);
|
||||||
|
|
||||||
freeswitch.consoleLog("NOTICE", "[ring_group][destination] LOG OUT\n");
|
freeswitch.consoleLog("NOTICE", "[ring_group][destination] LOG OUT\n");
|
||||||
session:streamFile("ivr/ivr-you_are_now_logged_out.wav");
|
session:streamFile("ivr/ivr-you_are_now_logged_out.wav");
|
||||||
|
|||||||
Reference in New Issue
Block a user