From 6030843ca8c0572126ef886d142b6b5000ded344 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 22 Sep 2023 16:01:59 -0600 Subject: [PATCH] Fix follow-me 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. --- .../resources/scripts/app/follow_me/index.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/switch/resources/scripts/app/follow_me/index.lua b/app/switch/resources/scripts/app/follow_me/index.lua index 412017cd97..279e2b4e70 100644 --- a/app/switch/resources/scripts/app/follow_me/index.lua +++ b/app/switch/resources/scripts/app/follow_me/index.lua @@ -41,6 +41,7 @@ missed_call_data = session:getVariable("missed_call_data"); sip_to_user = session:getVariable("sip_to_user"); dialed_user = session:getVariable("dialed_user") or ''; + verto_enabled = session:getVariable("verto_enabled") or ''; end --set caller id @@ -409,6 +410,7 @@ end --process according to user_exists, sip_uri, external number + dial_string = ''; if (user_exists == "true") then --get the extension_uuid cmd = "user_data ".. destination_number .."@"..domain_name.." var extension_uuid"; @@ -429,8 +431,19 @@ end --send to user - local dial_string_to_user = "[sip_invite_domain="..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..record_session.."]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..",call_direction="..call_direction..","..group_confirm..","..timeout_name.."="..destination_timeout..","..delay_name.."="..destination_delay.."]" .. row.destination_number;