Update index.lua

This commit is contained in:
FusionPBX 2017-07-21 18:05:08 -06:00 committed by GitHub
parent b534caeddb
commit 8bd98f826b
1 changed files with 61 additions and 32 deletions

View File

@ -27,7 +27,8 @@
-- Mark J Crane <markjcrane@fusionpbx.com> -- Mark J Crane <markjcrane@fusionpbx.com>
-- Luis Daniel Lucio Qurioz <dlucio@okay.com.mx> -- Luis Daniel Lucio Qurioz <dlucio@okay.com.mx>
local log = require "resources.functions.log".ring_group --include the log
local log = require "resources.functions.log".ring_group
--connect to the database --connect to the database
local Database = require "resources.functions.database"; local Database = require "resources.functions.database";
@ -47,26 +48,57 @@ local log = require "resources.functions.log".ring_group
require "resources.functions.channel_utils" require "resources.functions.channel_utils"
require "resources.functions.format_ringback" require "resources.functions.format_ringback"
--get the variables --define the session hangup
domain_name = session:getVariable("domain_name"); function session_hangup_hook()
ring_group_uuid = session:getVariable("ring_group_uuid");
recordings_dir = session:getVariable("recordings_dir");
sounds_dir = session:getVariable("sounds_dir");
--variables that don't require ${} when used in the dialplan conditions --send info to the log
username = session:getVariable("username"); --freeswitch.consoleLog("notice","[ring_groups] originate_disposition: " .. session:getVariable("originate_disposition") .. "\n");
dialplan = session:getVariable("dialplan");
caller_id_name = session:getVariable("caller_id_name"); --run the missed called function
caller_id_number = session:getVariable("caller_id_number"); if (
network_addr = session:getVariable("network_addr"); session:getVariable("originate_disposition") == "ALLOTTED_TIMEOUT"
ani = session:getVariable("ani"); or session:getVariable("originate_disposition") == "NO_ANSWER"
aniii = session:getVariable("aniii"); or session:getVariable("originate_disposition") == "NO_USER_RESPONSE"
rdnis = session:getVariable("rdnis"); or session:getVariable("originate_disposition") == "USER_NOT_REGISTERED"
destination_number = session:getVariable("destination_number"); or session:getVariable("originate_disposition") == "NORMAL_TEMPORARY_FAILURE"
source = session:getVariable("source"); or session:getVariable("originate_disposition") == "NO_ROUTE_DESTINATION"
uuid = session:getVariable("uuid"); or session:getVariable("originate_disposition") == "USER_BUSY"
context = session:getVariable("context"); or session:getVariable("originate_disposition") == "RECOVERY_ON_TIMER_EXPIRE"
call_direction = session:getVariable("call_direction"); or session:getVariable("originate_disposition") == "failure"
or session:getVariable("originate_disposition") == "ORIGINATOR_CANCEL"
) then
--send missed call notification
missed();
end
end
--set the hangup hook function
if (session:ready()) then
session:setHangupHook("session_hangup_hook");
end
--get the variables
if (session:ready()) then
session:setAutoHangup(false);
domain_name = session:getVariable("domain_name");
ring_group_uuid = session:getVariable("ring_group_uuid");
recordings_dir = session:getVariable("recordings_dir");
sounds_dir = session:getVariable("sounds_dir");
username = session:getVariable("username");
dialplan = session:getVariable("dialplan");
caller_id_name = session:getVariable("caller_id_name");
caller_id_number = session:getVariable("caller_id_number");
network_addr = session:getVariable("network_addr");
ani = session:getVariable("ani");
aniii = session:getVariable("aniii");
rdnis = session:getVariable("rdnis");
destination_number = session:getVariable("destination_number");
source = session:getVariable("source");
uuid = session:getVariable("uuid");
context = session:getVariable("context");
call_direction = session:getVariable("call_direction");
end
--default to local if nil --default to local if nil
if (call_direction == nil) then if (call_direction == nil) then
@ -83,12 +115,14 @@ local log = require "resources.functions.log".ring_group
external = "false"; external = "false";
--set the sounds path for the language, dialect and voice --set the sounds path for the language, dialect and voice
default_language = session:getVariable("default_language"); if (session:ready()) then
default_dialect = session:getVariable("default_dialect"); default_language = session:getVariable("default_language");
default_voice = session:getVariable("default_voice"); default_dialect = session:getVariable("default_dialect");
if (not default_language) then default_language = 'en'; end default_voice = session:getVariable("default_voice");
if (not default_dialect) then default_dialect = 'us'; end if (not default_language) then default_language = 'en'; end
if (not default_voice) then default_voice = 'callie'; end if (not default_dialect) then default_dialect = 'us'; end
if (not default_voice) then default_voice = 'callie'; end
end
--get record_ext --get record_ext
record_ext = session:getVariable("record_ext"); record_ext = session:getVariable("record_ext");
@ -655,15 +689,11 @@ local log = require "resources.functions.log".ring_group
or session:getVariable("originate_disposition") == "RECOVERY_ON_TIMER_EXPIRE" or session:getVariable("originate_disposition") == "RECOVERY_ON_TIMER_EXPIRE"
or session:getVariable("originate_disposition") == "failure" or session:getVariable("originate_disposition") == "failure"
) then ) then
--send missed call notification
missed();
--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);
end end
else else
if (ring_group_timeout_app ~= nil) then if (ring_group_timeout_app ~= nil) then
--send missed call notification
missed();
--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
@ -674,14 +704,13 @@ local log = require "resources.functions.log".ring_group
freeswitch.consoleLog("notice", "[ring group] SQL:" .. sql .. "; params:" .. json.encode(params) .. "\n"); freeswitch.consoleLog("notice", "[ring group] SQL:" .. sql .. "; params:" .. json.encode(params) .. "\n");
end end
dbh:query(sql, params, function(row) dbh:query(sql, params, function(row)
--send missed call notification
missed();
--execute the time out action --execute the time out action
session:execute(row.ring_group_timeout_app, row.ring_group_timeout_data); session:execute(row.ring_group_timeout_app, row.ring_group_timeout_data);
end); end);
end end
end end
end end
end end
--actions --actions