From b0a2f3340a2f06be1341c53e34fbb8ebd5ef8056 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 22 Sep 2023 16:23:14 -0600 Subject: [PATCH] Fix ring group delay timing Use sofia_contact instead of user bridge alias. Added a useful note from @greenbea describing why there was a problem with follow me delay timing. When you originate user/ext@domain, switch_ivr_originate will call the user endpoint. The user endpoint isn't a real endpoint. It is a shortcut to get the real dialstring from the user's XML and calls again switch_ivr_originate, so essentially, what happens is switch_ivr_originate reads twice originate_delay_start variable and waits double the time. Your patch fixes the case when the endpoint is the user/ endpoint but will make the delay half the time if called with other endpoints like sofia. The ultimate solution would be freeswitch to handle this in the user endpoint function. I would suggest that fusion manually get the user's dial string from the XML and call originate on it and not rely on the user (shortcut) endpoint for ring group and follow me. --- .../scripts/app/ring_groups/index.lua | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/app/switch/resources/scripts/app/ring_groups/index.lua b/app/switch/resources/scripts/app/ring_groups/index.lua index 02bcf19c9f..79729f24ab 100644 --- a/app/switch/resources/scripts/app/ring_groups/index.lua +++ b/app/switch/resources/scripts/app/ring_groups/index.lua @@ -163,7 +163,8 @@ context = session:getVariable("context"); call_direction = session:getVariable("call_direction"); accountcode = session:getVariable("accountcode"); - local_ip_v4 = session:getVariable("local_ip_v4") + local_ip_v4 = session:getVariable("local_ip_v4"); + verto_enabled = session:getVariable("verto_enabled") or ''; end --set caller id @@ -834,8 +835,19 @@ end --send to user - local dial_string_to_user = "[sip_invite_domain="..domain_name..",domain_name="..domain_name..",call_direction="..call_direction..","..group_confirm..""..timeout_name.."="..destination_timeout..","..delay_name.."="..destination_delay..",dialed_extension=" .. row.destination_number .. ",extension_uuid=".. extension_uuid .. row.record_session .. hold_music .."]user/" .. row.destination_number .. "@" .. domain_name; - dial_string = dial_string_to_user; + local dial_string_user = "[sip_invite_domain="..domain_name..",call_direction="..call_direction..","; + dial_string_user = dial_string_user .. group_confirm..","..timeout_name.."="..destination_timeout..","; + dial_string_user = dial_string_user .. delay_name.."="..destination_delay..","; + dial_string_user = dial_string_user .. "dialed_extension=" .. row.destination_number .. ","; + dial_string_user = dial_string_user .. "presence_id=" .. row.destination_number .. "@"..domain_name..","; + dial_string_user = dial_string_user .. "extension_uuid="..extension_uuid..record_session.."]"; + user_contact = api:executeString("sofia_contact */".. row.destination_number .."@" ..domain_name); + if (user_contact ~= "error/user_not_registered") then + dial_string = dial_string_user .. user_contact; + end + if (verto_enabled == 'true') then + dial_string = dial_string .. ","..api:executeString("verto_contact ".. row.destination_number .."@" ..domain_name); + end elseif (tonumber(destination_number) == nil) then --sip uri dial_string = "[sip_invite_domain="..domain_name..",domain_name="..domain_name..",call_direction="..call_direction..","..group_confirm..""..timeout_name.."="..destination_timeout..","..delay_name.."="..destination_delay.."]" .. row.destination_number;