mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-02-21 18:36:31 +00:00
Add ring group call screening
This commit is contained in:
@@ -48,6 +48,7 @@ log = require "resources.functions.log".ring_group
|
||||
require "resources.functions.channel_utils"
|
||||
require "resources.functions.format_ringback"
|
||||
require "resources.functions.send_presence";
|
||||
require "resources.functions.mkdir";
|
||||
|
||||
--- include libs
|
||||
local route_to_bridge = require "resources.functions.route_to_bridge"
|
||||
@@ -239,6 +240,7 @@ log = require "resources.functions.log".ring_group
|
||||
ring_group_caller_id_number = row["ring_group_caller_id_number"];
|
||||
ring_group_cid_name_prefix = row["ring_group_cid_name_prefix"];
|
||||
ring_group_cid_number_prefix = row["ring_group_cid_number_prefix"];
|
||||
ring_group_call_screen_enabled = row["ring_group_call_screen_enabled"];
|
||||
ring_group_call_forward_enabled = row["ring_group_call_forward_enabled"];
|
||||
ring_group_follow_me_enabled = row["ring_group_follow_me_enabled"];
|
||||
missed_call_app = row["ring_group_missed_call_app"];
|
||||
@@ -249,6 +251,14 @@ log = require "resources.functions.log".ring_group
|
||||
local Settings = require "resources.functions.lazy_settings";
|
||||
local settings = Settings.new(dbh, domain_name, domain_uuid);
|
||||
|
||||
--get the recordings dir
|
||||
--recordings_dir = settings:get('switch', 'recordings', 'dir');
|
||||
|
||||
--set the default record extension
|
||||
if (record_ext == nil) then
|
||||
record_ext = 'wav';
|
||||
end
|
||||
|
||||
--prepare the recording path
|
||||
record_path = recordings_dir .. "/" .. domain_name .. "/archive/" .. os.date("%Y/%b/%d");
|
||||
record_path = record_path:gsub("\\", "/");
|
||||
@@ -284,9 +294,55 @@ log = require "resources.functions.log".ring_group
|
||||
if (session:ready()) then
|
||||
if (ring_group_greeting and #ring_group_greeting > 0) then
|
||||
session:answer();
|
||||
session_answer = true
|
||||
session:sleep(1000);
|
||||
play_file(dbh, domain_name, domain_uuid, ring_group_greeting)
|
||||
session:sleep(1000);
|
||||
else
|
||||
session_answer = false
|
||||
end
|
||||
end
|
||||
|
||||
--call screen enabled
|
||||
if (ring_group_call_screen_enabled == 'true') then
|
||||
|
||||
--answer the call if not answered
|
||||
if (not session_answer) then
|
||||
session:answer();
|
||||
end
|
||||
|
||||
--flush dtmf digits from the input buffer
|
||||
session:flushDigits();
|
||||
|
||||
--set the variables
|
||||
min_digits = 1;
|
||||
max_digits = 1;
|
||||
max_attempts = 1;
|
||||
timeout = 3000
|
||||
|
||||
--play the name record
|
||||
dtmf_digits = '';
|
||||
session:execute("playback", "phrase:voicemail_record_name");
|
||||
--session:execute("sleep", "1000");
|
||||
session:streamFile("tone_stream://L=1;%(1000, 0, 640)");
|
||||
|
||||
--recording settings
|
||||
max_length_seconds = 30;
|
||||
silence_threshold = 30;
|
||||
silence_seconds = 3;
|
||||
|
||||
--create the call scree file name
|
||||
call_sreen_name = 'call_screen.'..uuid..'.'..record_ext;
|
||||
|
||||
--make sure the recording directory exists
|
||||
if (not file_exists(record_path)) then
|
||||
mkdir(record_path);
|
||||
end
|
||||
|
||||
--record the name and reason for calling
|
||||
if (session:ready()) then
|
||||
result = session:recordFile(record_path..'/'..call_sreen_name, max_length_seconds, silence_threshold, silence_seconds);
|
||||
--session:execute("record", record_path..'/'..call_sreen_name.." 180 200");
|
||||
end
|
||||
end
|
||||
|
||||
@@ -853,7 +909,7 @@ log = require "resources.functions.log".ring_group
|
||||
user_hold_music = trim(api:executeString(cmd));
|
||||
if (user_hold_music ~= nil) and (string.len(user_hold_music) > 0) then
|
||||
hold_music = user_hold_music;
|
||||
else
|
||||
else
|
||||
hold_music = default_hold_music
|
||||
end
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
--
|
||||
-- The Initial Developer of the Original Code is
|
||||
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||
-- Copyright (C) 2010-2015
|
||||
-- Copyright (C) 2010-2024
|
||||
-- the Initial Developer. All Rights Reserved.
|
||||
--
|
||||
-- Contributor(s):
|
||||
-- Mark J Crane <markjcrane@fusionpbx.com>
|
||||
|
||||
--include config.lua
|
||||
require "resources.functions.config";
|
||||
require "resources.functions.config";
|
||||
|
||||
--set variables
|
||||
digit_timeout = "5000";
|
||||
@@ -40,7 +40,7 @@
|
||||
--session:sleep(1000);
|
||||
|
||||
--get the variables
|
||||
uuid = session:getVariable("uuid");
|
||||
call_uuid = session:getVariable("call_uuid");
|
||||
domain_name = session:getVariable("domain_name");
|
||||
context = session:getVariable("context");
|
||||
sounds_dir = session:getVariable("sounds_dir");
|
||||
@@ -64,12 +64,32 @@
|
||||
if (not default_dialect) then default_dialect = 'us'; end
|
||||
if (not default_voice) then default_voice = 'callie'; end
|
||||
|
||||
--create the settings object
|
||||
--local Settings = require "resources.functions.lazy_settings";
|
||||
--local settings = Settings.new(dbh, domain_name, domain_uuid);
|
||||
|
||||
--get the recordings dir
|
||||
--recordings_dir = settings:get('switch', 'recordings', 'dir');
|
||||
|
||||
--set the default record extension
|
||||
if (record_ext == nil) then
|
||||
record_ext = 'wav';
|
||||
end
|
||||
|
||||
--prepare the recording path
|
||||
record_path = recordings_dir .. "/" .. domain_name .. "/archive/" .. os.date("%Y/%b/%d");
|
||||
record_path = record_path:gsub("\\", "/");
|
||||
|
||||
--if the screen file is found then set confirm to true
|
||||
if (domain_name ~= nil) then
|
||||
if (file_exists(temp_dir .. "/" .. domain_name .. "-" .. caller_id_number .. "." .. record_ext)) then
|
||||
call_screen_file = temp_dir .. "/" .. domain_name .. "-" .. caller_id_number .. "." .. record_ext;
|
||||
confirm = "true";
|
||||
end
|
||||
if (file_exists(record_path.."/call_screen."..call_uuid .."."..record_ext)) then
|
||||
call_screen_file = record_path.."/call_screen."..call_uuid .."."..record_ext;
|
||||
confirm = "true";
|
||||
end
|
||||
end
|
||||
|
||||
--confirm the calls
|
||||
|
||||
Reference in New Issue
Block a user