Add. Use params in agent_status/index.lua (#2125)
This commit is contained in:
parent
bcdb99c6db
commit
041be65ccc
|
|
@ -6,8 +6,14 @@
|
||||||
debug["sql"] = true;
|
debug["sql"] = true;
|
||||||
|
|
||||||
--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
|
||||||
|
|
||||||
--set the api
|
--set the api
|
||||||
api = freeswitch.API();
|
api = freeswitch.API();
|
||||||
|
|
@ -66,14 +72,19 @@
|
||||||
end
|
end
|
||||||
|
|
||||||
--get the agent password
|
--get the agent password
|
||||||
sql = "SELECT * FROM v_call_center_agents ";
|
local params = {domain_uuid = domain_uuid, agent_id = agent_id}
|
||||||
sql = sql .. "WHERE domain_uuid = '" .. domain_uuid .."' ";
|
local sql = "SELECT * FROM v_call_center_agents ";
|
||||||
sql = sql .. "AND agent_id = '" .. agent_id .."' ";
|
sql = sql .. "WHERE domain_uuid = :domain_uuid ";
|
||||||
|
sql = sql .. "AND agent_id = :agent_id ";
|
||||||
if (agent_authorized ~= 'true') then
|
if (agent_authorized ~= 'true') then
|
||||||
sql = sql .. "AND agent_password = '" .. agent_password .."' ";
|
sql = sql .. "AND agent_password = :agent_password ";
|
||||||
|
params.agent_password = agent_password;
|
||||||
end
|
end
|
||||||
freeswitch.consoleLog("notice", "[user status] sql: " .. sql .. "\n");
|
if (debug["sql"]) then
|
||||||
dbh:query(sql, function(row)
|
freeswitch.consoleLog("notice", "[user status] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
|
end
|
||||||
|
|
||||||
|
dbh:query(sql, params, function(row)
|
||||||
--set the variables
|
--set the variables
|
||||||
agent_name = row.agent_name;
|
agent_name = row.agent_name;
|
||||||
agent_id = row.agent_id;
|
agent_id = row.agent_id;
|
||||||
|
|
@ -91,13 +102,14 @@
|
||||||
|
|
||||||
--get the user_uuid
|
--get the user_uuid
|
||||||
if (agent_authorized == 'true') then
|
if (agent_authorized == 'true') then
|
||||||
sql = "SELECT user_uuid, user_status FROM v_users ";
|
local sql = "SELECT user_uuid, user_status FROM v_users ";
|
||||||
sql = sql .. "WHERE username = '".. agent_name .."' ";
|
sql = sql .. "WHERE username = :agent_name ";
|
||||||
sql = sql .. "AND domain_uuid = '" .. domain_uuid .."' ";
|
sql = sql .. "AND domain_uuid = :domain_uuid ";
|
||||||
|
local params = {agent_name = agent_name, domain_uuid = domain_uuid};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("NOTICE", "[call_center] sql: ".. sql .. "\n");
|
freeswitch.consoleLog("notice", "[call_center] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
dbh:query(sql, function(row)
|
dbh:query(sql, params, function(row)
|
||||||
--get the user info
|
--get the user info
|
||||||
user_uuid = row.user_uuid;
|
user_uuid = row.user_uuid;
|
||||||
user_status = row.user_status;
|
user_status = row.user_status;
|
||||||
|
|
@ -113,13 +125,14 @@
|
||||||
freeswitch.consoleLog("NOTICE", "[call_center] user_status: ".. status .. "\n");
|
freeswitch.consoleLog("NOTICE", "[call_center] user_status: ".. status .. "\n");
|
||||||
|
|
||||||
--set the user_status in the users table
|
--set the user_status in the users table
|
||||||
sql = "UPDATE v_users SET ";
|
local sql = "UPDATE v_users SET ";
|
||||||
sql = sql .. "user_status = '"..status.."' ";
|
sql = sql .. "user_status = :status ";
|
||||||
sql = sql .. "WHERE user_uuid = '" .. user_uuid .."' ";
|
sql = sql .. "WHERE user_uuid = :user_uuid ";
|
||||||
|
local params = {status = status, user_uuid = user_uuid};
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("NOTICE", "[call_center] sql: ".. sql .. "\n");
|
freeswitch.consoleLog("notice", "[call_center] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n");
|
||||||
end
|
end
|
||||||
dbh:query(sql);
|
dbh:query(sql, params);
|
||||||
|
|
||||||
--send a login or logout to mod_callcenter
|
--send a login or logout to mod_callcenter
|
||||||
cmd = "callcenter_config agent set status "..agent_name.."@"..domain_name.." '"..status.."'";
|
cmd = "callcenter_config agent set status "..agent_name.."@"..domain_name.." '"..status.."'";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue