Replace show channels like

Like statement failed for a customer replaced with show channels then search the results to destination is available or busy.
This commit is contained in:
FusionPBX 2021-08-02 16:47:47 -06:00 committed by GitHub
parent 08ee1d0cd6
commit 2bcb3b343b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 32 deletions

View File

@ -163,39 +163,30 @@
--prevent calling the user that initiated the page
if (sip_from_user ~= destination) then
--cmd = "username_exists id "..destination.."@"..domain_name;
--reply = trim(api:executeString(cmd));
--if (reply == "true") then
destination_status = "show channels like "..destination.."@";
reply = trim(api:executeString(destination_status));
if (reply == "0 total.") 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
--freeswitch.consoleLog("NOTICE", "cmd_string "..cmd_string.."\n");
else
--look inside the reply to check for the correct domain_name
if string.find(reply, domain_name, nil, true) then
--found: user is busy
else
--not found
if (destination == tonumber(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,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
cmd_string = "show channels";
channel_result = api:executeString(cmd_string);
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
--end
end
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