From 5a89fa5081367809335c339c7a3e3446baf08c13 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Fri, 27 May 2022 14:45:41 -0600 Subject: [PATCH] Remove code from checks to see if the extension is on the phone. Having the PBX check if the caller is already on the phone has not worked well at least not the approach that is getting removed in this commit. It is not the right way to solve the issue. Its better for the phone endpoint to block the intercom or auto answer when it is already on a call. One way to do this that worked in testing was to disable call waiting. Then the call is rejected and not allowed to interrupt. the call that already exists. Expect there are also other ways to instruct the phone not to interrupt active calls when it receives a SIP message to auto answer. --- app/scripts/resources/scripts/page.lua | 39 +++++++++----------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/app/scripts/resources/scripts/page.lua b/app/scripts/resources/scripts/page.lua index 323231ddc3..0f0de5479f 100644 --- a/app/scripts/resources/scripts/page.lua +++ b/app/scripts/resources/scripts/page.lua @@ -1,6 +1,6 @@ -- page.lua -- Part of FusionPBX --- Copyright (C) 2010 Mark J Crane +-- Copyright (C) 2010-2022 Mark J Crane -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without @@ -152,10 +152,11 @@ end end - --get the channels + --log the destinations + freeswitch.consoleLog("NOTICE", "[page] destinations "..destinations.." available\n"); + + --create the api object api = freeswitch.API(); - cmd_string = "show channels"; - channel_result = api:executeString(cmd_string); --originate the calls destination_count = 0; @@ -168,29 +169,15 @@ --prevent calling the user that initiated the page if (sip_from_user ~= destination) then - - --loop through channels to determine if destination is available or busy - destination_status = 'available'; - channel_array = explode("\n", channel_result); - for index,row in pairs(channel_array) do - if string.find(row, destination..'@'..domain_name, nil, true) then - destination_status = 'busy'; - end + freeswitch.consoleLog("NOTICE", "[page] destination "..destination.." available\n"); + if destination == sip_from_user then + --this destination is the caller that initated the page + else + --originate the call + cmd_string = "bgapi originate {sip_auto_answer=true,sip_h_Alert-Info='Ring Answer',hangup_after_bridge=false,rtp_secure_media="..rtp_secure_media..",origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:"..conference_bridge.."+"..flags.." inline"; + api:executeString(cmd_string); + destination_count = destination_count + 1; end - - --if available then page then originate the call with auto answer - if (destination_status == 'available') then - freeswitch.consoleLog("NOTICE", "[page] destination "..destination.." available\n"); - if destination == sip_from_user then - --this destination is the caller that initated the page - else - --originate the call - cmd_string = "bgapi originate {sip_auto_answer=true,sip_h_Alert-Info='Ring Answer',hangup_after_bridge=false,rtp_secure_media="..rtp_secure_media..",origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:"..conference_bridge.."+"..flags.." inline"; - api:executeString(cmd_string); - destination_count = destination_count + 1; - end - end - end end end