mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-03 10:23:50 +00:00
Check add the option to record the user.
This commit is contained in:
@@ -31,10 +31,12 @@
|
||||
-- dir /usr/local/freeswitch/scripts -1
|
||||
|
||||
--set local variables
|
||||
local context = session:getVariable("context");
|
||||
local destination_number = session:getVariable("destination_number");
|
||||
local call_direction = session:getVariable("call_direction");
|
||||
local domain_name = session:getVariable("domain_name");
|
||||
uuid = session:getVariable("uuid");
|
||||
context = session:getVariable("context");
|
||||
destination_number = session:getVariable("destination_number");
|
||||
call_direction = session:getVariable("call_direction");
|
||||
domain_name = session:getVariable("domain_name");
|
||||
recordings_dir = session:getVariable("recordings_dir");
|
||||
|
||||
--determine the call direction
|
||||
if (call_direction == nil) then
|
||||
@@ -72,6 +74,17 @@
|
||||
end
|
||||
end
|
||||
|
||||
--include before
|
||||
result = assert (io.popen ("dir " ..scripts_dir.."/app/dialplan/resources/before /b -1"));
|
||||
for file in result:lines() do
|
||||
if (string.sub(file, -4) == ".lua") then
|
||||
if file_exists(scripts_dir.."/app/dialplan/resources/before/"..file) then
|
||||
dofile(scripts_dir.."/app/dialplan/resources/before/"..file);
|
||||
end
|
||||
--freeswitch.consoleLog("notice", "[app:dialplan] lua: before/" .. file .. "\n");
|
||||
end
|
||||
end
|
||||
|
||||
--include the dialplans
|
||||
result = assert (io.popen ("dir " ..scripts_dir.."/app/dialplan/resources/"..dialplan_dir.." /b -1"));
|
||||
for file in result:lines() do
|
||||
@@ -79,6 +92,17 @@
|
||||
if file_exists(scripts_dir.."/app/dialplan/resources/"..dialplan_dir.."/"..file) then
|
||||
dofile(scripts_dir.."/app/dialplan/resources/"..dialplan_dir.."/"..file);
|
||||
end
|
||||
freeswitch.consoleLog("notice", "[app:dialplan] lua: "..dialplan_dir.."/" .. file .. "\n");
|
||||
--freeswitch.consoleLog("notice", "[app:dialplan] lua: "..dialplan_dir.."/" .. file .. "\n");
|
||||
end
|
||||
end
|
||||
|
||||
--include after
|
||||
result = assert (io.popen ("dir " ..scripts_dir.."/app/dialplan/resources/after /b -1"));
|
||||
for file in result:lines() do
|
||||
if (string.sub(file, -4) == ".lua") then
|
||||
if file_exists(scripts_dir.."/app/dialplan/resources/after/"..file) then
|
||||
dofile(scripts_dir.."/app/dialplan/resources/after/"..file);
|
||||
end
|
||||
--freeswitch.consoleLog("notice", "[app:dialplan] lua: after/" .. file .. "\n");
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
--set the user_exists to true or false
|
||||
if (context ~= "public") then
|
||||
--set the recording path
|
||||
path = recordings_dir
|
||||
if (domain_count > 1) then
|
||||
path = path.."/"..domain_name;
|
||||
end
|
||||
path = path.."/archive/"..(os.date("%Y")).."/"..(os.date("%b")).."/"..(os.date("%d")).."/"..uuid..".wav";
|
||||
|
||||
--check whether to record the to user
|
||||
if (user_exists == "true") then
|
||||
if (session:ready()) then
|
||||
--get user_variable -> record
|
||||
cmd = "user_data ".. destination_number .."@"..domain_name.." var user_record";
|
||||
user_record = trim(api:executeString(cmd));
|
||||
--freeswitch.consoleLog("notice", "[app:dialplan] " .. cmd .. "\n");
|
||||
|
||||
--set the record_session variable
|
||||
--uuid_record,<uuid> [start|stop|mask|unmask] <path> [<limit>],Record session audio,mod_commands
|
||||
if (user_record == "all") then
|
||||
record_session = true;
|
||||
end
|
||||
if (user_record == "inbound" and call_direction == "inbound") then
|
||||
record_session = true;
|
||||
end
|
||||
if (user_record == "outbound" and call_direction == "outbound") then
|
||||
record_session = true;
|
||||
end
|
||||
if (user_record == "local" and call_direction == "local") then
|
||||
record_session = true;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--check whether to record the from user
|
||||
if (not record_session) then
|
||||
--get the from user
|
||||
sip_from_user = session:getVariable("sip_from_user");
|
||||
sip_from_uri = session:getVariable("sip_from_uri");
|
||||
sip_from_host = session:getVariable("sip_from_host");
|
||||
|
||||
--get user exists true or false
|
||||
cmd = "user_exists id ".. sip_from_user .." "..sip_from_host;
|
||||
user_exists = trim(api:executeString(cmd));
|
||||
|
||||
--get user_variable -> record
|
||||
cmd = "user_data ".. sip_from_user .."@"..sip_from_host.." var user_record";
|
||||
freeswitch.consoleLog("notice", "[app:dialplan] " .. cmd .. "\n");
|
||||
user_record = trim(api:executeString(cmd));
|
||||
|
||||
--set the record_session variable
|
||||
--uuid_record,<uuid> [start|stop|mask|unmask] <path> [<limit>],Record session audio,mod_commands
|
||||
if (user_record == "all") then
|
||||
record_session = true;
|
||||
end
|
||||
if (user_record == "inbound" and call_direction == "inbound") then
|
||||
record_session = true;
|
||||
end
|
||||
if (user_record == "outbound" and call_direction == "outbound") then
|
||||
record_session = true;
|
||||
end
|
||||
if (user_record == "local" and call_direction == "local") then
|
||||
record_session = true;
|
||||
end
|
||||
end
|
||||
|
||||
--record the session
|
||||
if (record_session) then
|
||||
cmd = "uuid_record "..uuid.." start "..path;
|
||||
session:execute("set", "api_on_answer="..cmd);
|
||||
--freeswitch.consoleLog("notice", "[app:dialplan] "..cmd.."\n");
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
--set the user_exists to true or false
|
||||
if (context ~= "public") then
|
||||
if (user_exists == nil) then
|
||||
--get user exists true or false
|
||||
cmd = "user_exists id ".. destination_number .." "..domain_name;
|
||||
user_exists = trim(api:executeString(cmd));
|
||||
--freeswitch.consoleLog("notice", "[app:dialplan] "..cmd.." user_exists: "..user_exists.."\n");
|
||||
end
|
||||
end
|
||||
@@ -16,7 +16,7 @@
|
||||
--
|
||||
-- The Initial Developer of the Original Code is
|
||||
-- Gerrit Visser <gerrit308@gmail.com>
|
||||
-- Copyright (C) 2011
|
||||
-- Copyright (C) 2011-2014
|
||||
-- the Initial Developer. All Rights Reserved.
|
||||
--
|
||||
-- Contributor(s):
|
||||
@@ -56,7 +56,7 @@ This method causes the script to get its manadatory arguments directly from the
|
||||
local function logger(level, log, data)
|
||||
-- output data to console 'log' if debug level is on
|
||||
if string.find(params["loglevel"], level) then
|
||||
freeswitch.consoleLog(log, "[Call Block]: " .. data .. "\n")
|
||||
freeswitch.consoleLog(log, "[Call Block]: " .. data .. "\n");
|
||||
end
|
||||
end
|
||||
|
||||
@@ -66,7 +66,7 @@ This method causes the script to get its manadatory arguments directly from the
|
||||
|
||||
--log if not connect
|
||||
if dbh:connected() == false then
|
||||
logger("W", "NOTICE", "db was not connected")
|
||||
logger("W", "NOTICE", "db was not connected");
|
||||
end
|
||||
|
||||
-- We have a single command letter
|
||||
@@ -75,7 +75,7 @@ This method causes the script to get its manadatory arguments directly from the
|
||||
params["cmd"] = argv[1];
|
||||
|
||||
-- ensure that we have a fresh status on exit
|
||||
session:setVariable("call_block", "")
|
||||
session:setVariable("call_block", "");
|
||||
|
||||
--send to the log
|
||||
logger("D", "NOTICE", "params are: " .. string.format("'%s', '%s', '%s', '%s'", params["cid_num"],
|
||||
@@ -102,7 +102,7 @@ This method causes the script to get its manadatory arguments directly from the
|
||||
k = 0
|
||||
for v in string.gmatch(found_action, "[%w%.]+") do
|
||||
details[k] = v
|
||||
--logger("W", "INFO", "Details: " .. details[k])
|
||||
logger("W", "INFO", "Details: " .. details[k]);
|
||||
k = k + 1
|
||||
end
|
||||
dbh:query("UPDATE v_call_block SET call_block_count = " .. found_count + 1 .. " WHERE call_block_uuid = '" .. found_uuid .. "'")
|
||||
|
||||
Reference in New Issue
Block a user