diff --git a/resources/install/scripts/page.lua b/resources/install/scripts/page.lua index be7de749cf..d304116df2 100644 --- a/resources/install/scripts/page.lua +++ b/resources/install/scripts/page.lua @@ -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