Add required diversion header

This commit is contained in:
FusionPBX 2024-03-04 16:50:37 -07:00 committed by GitHub
parent 422a9d7eb6
commit 2553caa2b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 9 deletions

View File

@ -223,6 +223,14 @@
$apps[$x]['default_settings'][$y]['default_setting_value'] = "true"; $apps[$x]['default_settings'][$y]['default_setting_value'] = "true";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false"; $apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Enable or disable the feature to add a range of extensions."; $apps[$x]['default_settings'][$y]['default_setting_description'] = "Enable or disable the feature to add a range of extensions.";
$y++;
$apps[$x]['default_settings'][$y]['default_setting_uuid'] = "d25c1e2b-4098-408e-959b-c789ba4691e1";
$apps[$x]['default_settings'][$y]['default_setting_category'] = "ring_group";
$apps[$x]['default_settings'][$y]['default_setting_subcategory'] = "diversion_enabled";
$apps[$x]['default_settings'][$y]['default_setting_name'] = "boolean";
$apps[$x]['default_settings'][$y]['default_setting_value'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_enabled'] = "false";
$apps[$x]['default_settings'][$y]['default_setting_description'] = "Enable or disable the adding diversion header for external destinations.";
//schema details //schema details
$y=0; $y=0;

View File

@ -244,6 +244,10 @@
missed_call_data = row["ring_group_missed_call_data"]; missed_call_data = row["ring_group_missed_call_data"];
end); end);
--create the settings object
local Settings = require "resources.functions.lazy_settings";
local settings = Settings.new(dbh, domain_name, domain_uuid);
--prepare the recording path --prepare the recording path
record_path = recordings_dir .. "/" .. domain_name .. "/archive/" .. os.date("%Y/%b/%d"); record_path = recordings_dir .. "/" .. domain_name .. "/archive/" .. os.date("%Y/%b/%d");
record_path = record_path:gsub("\\", "/"); record_path = record_path:gsub("\\", "/");
@ -901,8 +905,22 @@
caller_id = caller_id .. ",origination_caller_id_number="..ring_group_caller_id_number..","; caller_id = caller_id .. ",origination_caller_id_number="..ring_group_caller_id_number..",";
end end
--set the diversion header
local diversion_enabled = settings:get('ring_group', 'diversion_enabled', 'boolean') or 'false';
if (diversion_enabled == 'true') then
if (caller_is_local == 'true' and outbound_caller_id_number ~= nil) then
diversion_caller_id = outbound_caller_id_number;
end
if (ring_group_caller_id_number ~= nil and ring_group_caller_id_number ~= '') then
diversion_caller_id = ring_group_caller_id_number;
end
diversion_header = "sip_h_Diversion=<sip:"..diversion_caller_id.."@"..domain_name..">;reason=unconditional,";
else
diversion_header = '';
end
--set the destination dial string --set the destination dial string
dial_string = "[toll_allow=".. toll_allow ..",".. caller_id ..",sip_invite_domain="..domain_name..",domain_name="..domain_name..",domain_uuid="..domain_uuid..",call_direction="..call_direction..","..group_confirm..""..timeout_name.."="..destination_timeout..","..delay_name.."="..destination_delay.."]"..route_bridge dial_string = "["..diversion_header.."toll_allow=".. toll_allow ..",".. caller_id ..",sip_invite_domain="..domain_name..",domain_name="..domain_name..",domain_uuid="..domain_uuid..",call_direction="..call_direction..","..group_confirm..""..timeout_name.."="..destination_timeout..","..delay_name.."="..destination_delay.."]"..route_bridge
end end
--add a delimiter between destinations --add a delimiter between destinations