Fix table name, variables and syntax Follow me Lua (#4609)

* Fix table name, variables and syntax Follow me Lua

Correct the wrong table name on line 123. Correct the param on line 126 and correct the syntax on line 347.

* Update index.lua

Missing AND in where clause.

* Change order of preference Caller ID

Changed order of preference for Caller ID. If user exists should take preference over Follow Me override select caller ID.

This is my preference and my opinion only. May not be the desired effect of others. Perhaps a select option to choose a preference like the following options: Set caller ID override all, Local user else Caller ID
This commit is contained in:
Stephen Forster
2019-10-01 02:18:27 +02:00
committed by FusionPBX
parent d3af3498a3
commit d72718ea9f

View File

@@ -120,10 +120,10 @@
if (follow_me_uuid ~= nil) then
local sql = "select cid_name_prefix, cid_number_prefix, ";
sql = sql .. "follow_me_enabled, follow_me_caller_id_uuid, follow_me_ignore_busy ";
sql = sql .. "from v_extensions ";
sql = sql .. "from v_follow_me ";
sql = sql .. "where domain_uuid = :domain_uuid ";
sql = sql .. "follow_me_uuid = :follow_me_uuid; ";
local params = {domain_uuid = domain_uuid,destination_number = destination_number};
sql = sql .. "and follow_me_uuid = :follow_me_uuid; ";
local params = {domain_uuid = domain_uuid,follow_me_uuid = follow_me_uuid};
if (debug["sql"]) then
freeswitch.consoleLog("notice", "SQL:" .. sql .. "; params: " .. json.encode(params) .. "\n");
end
@@ -323,6 +323,23 @@
toll_allow = '';
end
--get the destination caller id name and number
if (follow_me_caller_id_uuid ~= nil) then
local sql = "select destination_uuid, destination_number, destination_description, destination_caller_id_name, destination_caller_id_number ";
sql = sql .. "from v_destinations ";
sql = sql .. "where domain_uuid = :domain_uuid ";
sql = sql .. "and destination_uuid = :destination_uuid ";
sql = sql .. "order by destination_number asc ";
local params = {domain_uuid = domain_uuid, destination_uuid = follow_me_caller_id_uuid};
if (debug["sql"]) then
freeswitch.consoleLog("notice", "SQL:" .. sql .. "; params: " .. json.encode(params) .. "\n");
end
status = dbh:query(sql, params, function(field)
caller_id_name = field["destination_caller_id_name"];
caller_id_number = field["destination_caller_id_number"];
end);
end
--check if the user exists
if tonumber(caller_id_number) ~= nil then
cmd = "user_exists id ".. caller_id_number .." "..domain_name;
@@ -339,22 +356,6 @@
end
end
--get the destination caller id name and number
if (follow_me_caller_id_uuid ~= nil) then
local sql = "select destination_uuid, destination_number, destination_description, destination_caller_id_name, destination_caller_id_number ";
sql = sql .. "from v_destinations ";
sql = sql .. "where domain_uuid = :domain_uuid ";
sql = sql .. "and destination_uuid = 'destination_uuid' ";
sql = sql .. "order by destination_number asc ";
local params = {domain_uuid = domain_uuid, destination_uuid = follow_me_caller_id_uuid};
if (debug["sql"]) then
freeswitch.consoleLog("notice", "SQL:" .. sql .. "; params: " .. json.encode(params) .. "\n");
end
status = dbh:query(sql, params, function(field)
caller_id_name = field["destination_caller_id_name"];
caller_id_number = field["destination_caller_id_number"];
end);
end
--set the caller id
caller_id = '';