mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-02-15 07:35:01 +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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user