mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 11:43:50 +00:00
Merge branch 'master' into intercept_load_balance
# Conflicts: # resources/install/scripts/resources/functions/database.lua
This commit is contained in:
@@ -112,6 +112,7 @@ This method causes the script to get its manadatory arguments directly from the
|
||||
--set the cache
|
||||
if (found_cid_num) then -- caller id exists
|
||||
if (found_enabled == "true") then
|
||||
--set the cache
|
||||
cache = "found_cid_num=" .. found_cid_num .. "&found_uuid=" .. found_uuid .. "&found_enabled=" .. found_enabled .. "&found_action=" .. found_action .. "&found_count=" .. found_count;
|
||||
result = trim(api:execute("memcache", "set app:call_block:" .. params["domain_name"] .. ":" .. params["cid_num"] .. " '"..cache.."' "..expire["call_block"]));
|
||||
|
||||
@@ -172,15 +173,16 @@ This method causes the script to get its manadatory arguments directly from the
|
||||
if (source == "database") then
|
||||
dbh:query("UPDATE v_call_block SET call_block_count = " .. found_count + 1 .. " WHERE call_block_uuid = '" .. found_uuid .. "'")
|
||||
end
|
||||
session:setVariable("call_block", "block")
|
||||
session:execute("set", "call_blocked=true");
|
||||
logger("W", "NOTICE", "number " .. params["cid_num"] .. " blocked with " .. found_count .. " previous hits, domain_name: " .. params["domain_name"])
|
||||
if (found_action == "Reject") then
|
||||
session:hangup("CALL_REJECTED")
|
||||
end
|
||||
if (found_action == "Busy") then
|
||||
elseif (found_action == "Busy") then
|
||||
session:hangup("USER_BUSY")
|
||||
end
|
||||
if (details[0] =="Voicemail") then
|
||||
elseif (found_action =="Hold") then
|
||||
session:setAutoHangup(false)
|
||||
session:execute("transfer", "*9664")
|
||||
elseif (details[0] =="Voicemail") then
|
||||
session:setAutoHangup(false)
|
||||
session:execute("transfer", "*99" .. details[2] .. " XML " .. details[1])
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
-- notice, this list of conditions and the following disclaimer in the
|
||||
-- documentation and/or other materials provided with the distribution.
|
||||
--
|
||||
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
-- THIS SOFTWARE IS PROVIDED AS ''IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
-- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
-- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
@@ -385,7 +385,7 @@
|
||||
end
|
||||
|
||||
--check if someone has already joined the conference
|
||||
local_hostname = trim(api:execute("hostname", ""));
|
||||
local_hostname = trim(api:execute("switchname", ""));
|
||||
freeswitch.consoleLog("notice", "[conference center] local_hostname is " .. local_hostname .. "\n");
|
||||
sql = "SELECT hostname FROM channels WHERE application = 'conference' AND dest = '" .. destination_number .. "' AND cid_num <> '".. caller_id_number .."' LIMIT 1";
|
||||
if (debug["sql"]) then
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
-- Contributor(s):
|
||||
-- Mark J. Crane
|
||||
|
||||
--set the debug options
|
||||
debug["sql"] = false;
|
||||
|
||||
--create the api object
|
||||
api = freeswitch.API();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
-- notice, this list of conditions and the following disclaimer in the
|
||||
-- documentation and/or other materials provided with the distribution.
|
||||
--
|
||||
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
-- THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
-- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
-- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
-- AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
@@ -38,6 +38,7 @@ local log = require "resources.functions.log".ring_group
|
||||
require "resources.functions.explode";
|
||||
require "resources.functions.base64";
|
||||
require "resources.functions.file_exists";
|
||||
require "resources.functions.explode";
|
||||
|
||||
--get the variables
|
||||
domain_name = session:getVariable("domain_name");
|
||||
@@ -101,6 +102,7 @@ local log = require "resources.functions.log".ring_group
|
||||
status = dbh:query(sql, function(row)
|
||||
domain_uuid = row["domain_uuid"];
|
||||
ring_group_name = row["ring_group_name"];
|
||||
ring_group_extension = row["ring_group_extension"];
|
||||
ring_group_forward_enabled = row["ring_group_forward_enabled"];
|
||||
ring_group_forward_destination = row["ring_group_forward_destination"];
|
||||
ring_group_cid_name_prefix = row["ring_group_cid_name_prefix"];
|
||||
@@ -152,6 +154,9 @@ local log = require "resources.functions.log".ring_group
|
||||
subject = subject:gsub("${caller_id_name}", caller_id_name);
|
||||
subject = subject:gsub("${caller_id_number}", caller_id_number);
|
||||
subject = subject:gsub("${ring_group_name}", ring_group_name);
|
||||
subject = subject:gsub("${ring_group_extension}", ring_group_extension);
|
||||
subject = subject:gsub("${sip_to_user}", ring_group_name);
|
||||
subject = subject:gsub("${dialed_user}", ring_group_extension);
|
||||
subject = trim(subject);
|
||||
subject = '=?utf-8?B?'..base64.encode(subject)..'?=';
|
||||
|
||||
@@ -162,6 +167,9 @@ local log = require "resources.functions.log".ring_group
|
||||
body = body:gsub("${caller_id_name}", caller_id_name);
|
||||
body = body:gsub("${caller_id_number}", caller_id_number);
|
||||
body = body:gsub("${ring_group_name}", ring_group_name);
|
||||
body = body:gsub("${ring_group_extension}", ring_group_extension);
|
||||
body = body:gsub("${sip_to_user}", ring_group_name);
|
||||
body = body:gsub("${dialed_user}", ring_group_extension);
|
||||
body = body:gsub(" ", " ");
|
||||
body = body:gsub("%s+", "");
|
||||
body = body:gsub(" ", " ");
|
||||
@@ -436,12 +444,23 @@ local log = require "resources.functions.log".ring_group
|
||||
cmd = "show channels like "..destination_number;
|
||||
reply = trim(api:executeString(cmd));
|
||||
--freeswitch.consoleLog("notice", "[ring group] reply "..cmd.." " .. reply .. "\n");
|
||||
exploded_reply = {};
|
||||
exploded_reply = explode(",",reply);
|
||||
|
||||
if (reply == "0 total.") then
|
||||
dial_string = dial_string_to_user
|
||||
else
|
||||
if (string.find(reply, domain_name)) then
|
||||
--active call
|
||||
else
|
||||
idle_extension=true;
|
||||
|
||||
if (exploded_reply ~= nil) then
|
||||
for i,v in ipairs(exploded_reply) do
|
||||
if(v==destination_number.."@"..domain_name) then
|
||||
idle_extension=false;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if(idle_extension) then
|
||||
dial_string = dial_string_to_user;
|
||||
end
|
||||
end
|
||||
@@ -619,36 +638,27 @@ local log = require "resources.functions.log".ring_group
|
||||
app_data = app_data:gsub("%]", "}");
|
||||
end
|
||||
freeswitch.consoleLog("NOTICE", "[ring group] app_data: "..app_data.."\n");
|
||||
-- log.noticef("bridge begin: originate_disposition:%s answered:%s ready:%s bridged:%s", session:getVariable("originate_disposition"), session:answered() and "true" or "false", session:ready() and "true" or "false", session:bridged() and "true" or "false")
|
||||
session:execute("bridge", app_data);
|
||||
-- log.noticef("bridge done: originate_disposition:%s answered:%s ready:%s bridged:%s", session:getVariable("originate_disposition"), session:answered() and "true" or "false", session:ready() and "true" or "false", session:bridged() and "true" or "false")
|
||||
end
|
||||
|
||||
--timeout destination
|
||||
if (app_data ~= nil) then
|
||||
if ring_group_strategy == "enterprise"
|
||||
and ( true
|
||||
--- I see 2 errors here `failure` and `PICKED_OFF`
|
||||
--- but they be more. I think check `answered` is enough.
|
||||
-- or session:getVariable("originate_disposition") == "failure"
|
||||
-- or session:getVariable("originate_disposition") == "PICKED_OFF"
|
||||
)
|
||||
and session:answered() then
|
||||
-- for enterprise calls when intercept we get "failure" but session answered
|
||||
return
|
||||
end
|
||||
|
||||
if (session:getVariable("originate_disposition") == "ALLOTTED_TIMEOUT"
|
||||
if session:ready() and (
|
||||
session:getVariable("originate_disposition") == "ALLOTTED_TIMEOUT"
|
||||
or session:getVariable("originate_disposition") == "NO_ANSWER"
|
||||
or session:getVariable("originate_disposition") == "NO_USER_RESPONSE"
|
||||
or session:getVariable("originate_disposition") == "USER_NOT_REGISTERED"
|
||||
or session:getVariable("originate_disposition") == "NORMAL_TEMPORARY_FAILURE"
|
||||
or session:getVariable("originate_disposition") == "NO_ROUTE_DESTINATION"
|
||||
or session:getVariable("originate_disposition") == "USER_BUSY"
|
||||
or session:getVariable("originate_disposition") == "failure") then
|
||||
--send missed call notification
|
||||
missed();
|
||||
--execute the time out action
|
||||
session:execute(ring_group_timeout_app, ring_group_timeout_data);
|
||||
or session:getVariable("originate_disposition") == "failure"
|
||||
) then
|
||||
--send missed call notification
|
||||
missed();
|
||||
--execute the time out action
|
||||
session:execute(ring_group_timeout_app, ring_group_timeout_data);
|
||||
end
|
||||
else
|
||||
if (ring_group_timeout_app ~= nil) then
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
skip_instructions = session:getVariable("skip_instructions");
|
||||
skip_greeting = session:getVariable("skip_greeting");
|
||||
vm_message_ext = session:getVariable("vm_message_ext");
|
||||
vm_say_caller_id_number = session:getVariable("vm_say_caller_id_number");
|
||||
vm_disk_quota = session:getVariable("vm-disk-quota");
|
||||
if (not vm_disk_quota) then
|
||||
vm_disk_quota = session:getVariable("vm_disk_quota");
|
||||
|
||||
@@ -31,20 +31,34 @@
|
||||
max_digits = 1;
|
||||
--flush dtmf digits from the input buffer
|
||||
session:flushDigits();
|
||||
--set the callback function
|
||||
if (session:ready()) then
|
||||
session:setVariable("playback_terminators", "#");
|
||||
session:setInputCallback("on_dtmf", "");
|
||||
end
|
||||
--set the display
|
||||
if (session:ready()) then
|
||||
reply = api:executeString("uuid_display "..session:get_uuid().." "..caller_id_number);
|
||||
end
|
||||
--say the message number
|
||||
if (session:ready()) then
|
||||
if (string.len(dtmf_digits) == 0) then
|
||||
if (string.len(dtmf_digits) == 0) then
|
||||
dtmf_digits = macro(session, "message_number", 1, 100, '');
|
||||
end
|
||||
end
|
||||
--say the number
|
||||
if (session:ready()) then
|
||||
if (string.len(dtmf_digits) == 0) then
|
||||
session:say(message_number, default_language, "NUMBER", "pronounced");
|
||||
session:say(message_number, default_language, "number", "pronounced");
|
||||
end
|
||||
end
|
||||
--say the caller id number
|
||||
if (session:ready() and caller_id_number ~= nil) then
|
||||
if (vm_say_caller_id_number ~= nil) then
|
||||
if (vm_say_caller_id_number == "true") then
|
||||
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-message_from.wav");
|
||||
session:say(caller_id_number, default_language, "name_spelled", "iterated");
|
||||
end
|
||||
end
|
||||
end
|
||||
--say the message date
|
||||
@@ -53,10 +67,9 @@
|
||||
if (current_time_zone ~= nil) then
|
||||
session:execute("set", "timezone="..current_time_zone.."");
|
||||
end
|
||||
session:say(created_epoch, default_language, "CURRENT_DATE_TIME", "pronounced");
|
||||
session:say(created_epoch, default_language, "current_date_time", "pronounced");
|
||||
end
|
||||
end
|
||||
|
||||
--get the recordings from the database
|
||||
if (storage_type == "base64") then
|
||||
sql = [[SELECT * FROM v_voicemail_messages
|
||||
|
||||
@@ -131,6 +131,8 @@
|
||||
body = body:gsub("${message_duration}", message_length_formatted);
|
||||
body = body:gsub("${account}", id);
|
||||
body = body:gsub("${domain_name}", domain_name);
|
||||
body = body:gsub("${sip_to_user}", id);
|
||||
body = body:gsub("${dialed_user}", id);
|
||||
if (voicemail_file == "attach") then
|
||||
body = body:gsub("${message}", text['label-attached'][default_language.."-"..default_dialect]);
|
||||
elseif (voicemail_file == "link") then
|
||||
|
||||
@@ -23,22 +23,6 @@
|
||||
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--set defaults
|
||||
expire = {}
|
||||
expire["directory"] = "3600";
|
||||
expire["dialplan"] = "3600";
|
||||
expire["languages"] = "3600";
|
||||
expire["sofia.conf"] = "3600";
|
||||
expire["acl.conf"] = "3600";
|
||||
load_balancing = false;
|
||||
|
||||
--set the debug options
|
||||
debug["params"] = false;
|
||||
debug["sql"] = false;
|
||||
debug["xml_request"] = false;
|
||||
debug["xml_string"] = false;
|
||||
debug["cache"] = false;
|
||||
|
||||
--general functions
|
||||
require "resources.functions.trim";
|
||||
require "resources.functions.file_exists";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- xml_handler.lua
|
||||
-- Part of FusionPBX
|
||||
-- Copyright (C) 2013 Mark J Crane <markjcrane@fusionpbx.com>
|
||||
-- Copyright (C) 2013 - 2015 Mark J Crane <markjcrane@fusionpbx.com>
|
||||
-- All rights reserved.
|
||||
--
|
||||
-- Redistribution and use in source and binary forms, with or without
|
||||
@@ -116,9 +116,10 @@
|
||||
sql = sql .. "and g.enabled = 'true' ";
|
||||
sql = sql .. "and (g.domain_uuid = d.domain_uuid or g.domain_uuid is null) ";
|
||||
else
|
||||
sql = "select * from v_gateways ";
|
||||
sql = sql .. "where enabled = 'true' and profile = '"..sip_profile_name.."' ";
|
||||
sql = "select * from v_gateways as g ";
|
||||
sql = sql .. "where g.enabled = 'true' and g.profile = '"..sip_profile_name.."' ";
|
||||
end
|
||||
sql = sql .. "and (g.hostname = '" .. hostname.. "' or g.hostname is null or g.hostname = '') ";
|
||||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n");
|
||||
end
|
||||
|
||||
@@ -99,13 +99,13 @@
|
||||
dialed_extension = params:getHeader("dialed_extension");
|
||||
if (dialed_extension == nil) then
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] dialed_extension is null\n");
|
||||
load_balancing = false;
|
||||
xml_handler["fs_path"] = false;
|
||||
else
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] dialed_extension is " .. dialed_extension .. "\n");
|
||||
end
|
||||
|
||||
--build the XML string from the database
|
||||
if (source == "database") or (load_balancing) then
|
||||
if (source == "database") or (xml_handler["fs_path"]) then
|
||||
--database connection
|
||||
if (continue) then
|
||||
--connect to the database
|
||||
@@ -138,7 +138,7 @@
|
||||
|
||||
--if load balancing is set to true then get the hostname
|
||||
if (continue) then
|
||||
if (load_balancing) then
|
||||
if (xml_handler["fs_path"]) then
|
||||
|
||||
--get the domain_name from domains
|
||||
if (domain_name == nil) then
|
||||
@@ -181,9 +181,9 @@
|
||||
--freeswitch.consoleLog("notice", "[xml_handler] sql: " .. sql .. "\n");
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] database_hostname is " .. database_hostname .. "\n");
|
||||
|
||||
--hostname was not found set load_balancing to false to prevent a database_hostname concatenation error
|
||||
--hostname was not found set xml_handler["fs_path"] to false to prevent a database_hostname concatenation error
|
||||
if (database_hostname == nil) then
|
||||
load_balancing = false;
|
||||
xml_handler["fs_path"] = false;
|
||||
end
|
||||
|
||||
--close the database connection
|
||||
@@ -261,7 +261,7 @@
|
||||
dial_string = "{sip_invite_domain=" .. domain_name .. ",presence_id=" .. user .. "@" .. domain_name .. "}${sofia_contact(" .. extension .. "@" .. domain_name .. ")}";
|
||||
end
|
||||
--set the an alternative dial string if the hostnames don't match
|
||||
if (load_balancing) then
|
||||
if (xml_handler["fs_path"]) then
|
||||
if (local_hostname == database_hostname) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler-directory.lua] local_host and database_host are the same\n");
|
||||
else
|
||||
@@ -271,13 +271,13 @@
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] dial_string " .. dial_string .. "\n");
|
||||
end
|
||||
else
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] seems balancing is false??" .. tostring(load_balancing) .. "\n");
|
||||
--freeswitch.consoleLog("notice", "[xml_handler-directory.lua] seems balancing is false??" .. tostring(xml_handler["fs_path"]) .. "\n");
|
||||
end
|
||||
|
||||
--show debug informationa
|
||||
--if (load_balancing) then
|
||||
-- freeswitch.consoleLog("notice", "[xml_handler] local_hostname: " .. local_hostname.. " database_hostname: " .. database_hostname .. " dial_string: " .. dial_string .. "\n");
|
||||
--end
|
||||
if (xml_handler["fs_path"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] local_hostname: " .. local_hostname.. " database_hostname: " .. database_hostname .. " dial_string: " .. dial_string .. "\n");
|
||||
end
|
||||
end
|
||||
end);
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--set the time between loops in seconds
|
||||
sleep = 300;
|
||||
sleep = 60;
|
||||
|
||||
--set the debug level
|
||||
debug["log"] = false;
|
||||
|
||||
@@ -391,7 +391,7 @@
|
||||
--email_cmd = "/bin/echo '"..email_message_fail.."' | /usr/bin/mail -s 'Fax to: "..number_dialed.." FAILED' -r "..from_address.." -a '"..fax_file.."' "..email_address;
|
||||
|
||||
--to keep the originate command shorter these are things we always send. One place to adjust for all.
|
||||
originate_same = "for_fax=1,absolute_codec_string='PCMU,PCMA',accountcode='"..accountcode.."',domain_uuid="..domain_uuid..",domain_name="..domain_name..",mailto_address='"..email_address.."',mailfrom_address='"..from_address.."',origination_caller_id_name='"..origination_caller_id_name.. "',origination_caller_id_number="..origination_caller_id_number..",fax_uri="..fax_uri..",fax_retry_limit="..fax_retry_limit..",fax_retry_sleep="..fax_retry_sleep..",fax_verbose=true,fax_file='"..fax_file.."'";
|
||||
originate_same = "for_fax=1,accountcode='"..accountcode.."',domain_uuid="..domain_uuid..",domain_name="..domain_name..",mailto_address='"..email_address.."',mailfrom_address='"..from_address.."',origination_caller_id_name='"..origination_caller_id_name.. "',origination_caller_id_number="..origination_caller_id_number..",fax_uri="..fax_uri..",fax_retry_limit="..fax_retry_limit..",fax_retry_sleep="..fax_retry_sleep..",fax_verbose=true,fax_file='"..fax_file.."'";
|
||||
|
||||
if (fax_retry_attempts < fax_retry_limit) then
|
||||
|
||||
|
||||
Reference in New Issue
Block a user