Paging - Prevent calling the user that initiated the page

This commit is contained in:
Mark Crane 2014-11-03 18:57:01 +00:00
parent 3c43f604c5
commit d79e72141d
1 changed files with 28 additions and 25 deletions

View File

@ -131,39 +131,42 @@ if ( session:ready() ) then
--get the destination required for number-alias
destination = api:execute("user_data", destination .. "@" .. domain_name .. " attr id");
--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", "destination "..destination.." available\n");
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,sip_h_Alert-Info='Ring Answer',hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:page-"..destination_number.."@page+"..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) then
--found: user is busy
else
--not found
--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", "destination "..destination.." available\n");
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,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:page-"..destination_number.."@page+"..flags.." inline";
cmd_string = "bgapi originate {sip_auto_answer=true,sip_h_Alert-Info='Ring Answer',hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:page-"..destination_number.."@page+"..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) 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,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:page-"..destination_number.."@page+"..flags.." inline";
api:executeString(cmd_string);
destination_count = destination_count + 1;
end
end
end
end
--end
--end
end
end
end