Merge pull request #1045 from moteus/page_domain

Page domain
This commit is contained in:
FusionPBX
2015-07-18 12:47:55 -07:00

View File

@@ -67,6 +67,8 @@ if ( session:ready() ) then
if (not default_dialect) then default_dialect = 'us'; end
if (not default_voice) then default_voice = 'callie'; end
local conf_name = "page-"..destination_number.."%"..domain_name.."@page"
if (caller_id_name) then
--caller id name provided do nothing
else
@@ -82,14 +84,10 @@ if ( session:ready() ) then
end
--set conference flags
if (mute) then
if (mute == "false") then
flags = "flags{}";
else
flags = "flags{mute}";
end
else
if (mute == "true") then
flags = "flags{mute}";
else
flags = "flags{}";
end
--if the pin number is provided then require it
@@ -129,7 +127,7 @@ if ( session:ready() ) then
sub_table = explode("-",value);
for destination=sub_table[1],sub_table[2] do
--get the destination required for number-alias
destination = api:execute("user_data", destination .. "@" .. domain_name .. " attr id");
destination = api:execute("user_data", destination .. "@" .. domain_name .. " attr id");
--prevent calling the user that initiated the page
if (sip_from_user ~= destination) then
@@ -139,12 +137,12 @@ if ( session:ready() ) 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");
freeswitch.consoleLog("NOTICE", "[page] 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";
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:"..conf_name.."+"..flags.." inline";
api:executeString(cmd_string);
destination_count = destination_count + 1;
end
@@ -159,7 +157,7 @@ if ( session:ready() ) 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,hangup_after_bridge=false,origination_caller_id_name='"..caller_id_name.."',origination_caller_id_number="..caller_id_number.."}user/"..destination.."@"..domain_name.." conference:" ..conf_name"+"..flags.." inline";
api:executeString(cmd_string);
destination_count = destination_count + 1;
end
@@ -172,12 +170,12 @@ if ( session:ready() ) then
--send main call to the conference room
if (destination_count > 0) then
if (session:getVariable("moderator") ~= nil and session:getVariable("moderator") == "true") then
if (session:getVariable("moderator") == "true") then
moderator_flag = ",moderator";
else
moderator_flag = "";
end
session:execute("conference", "page-"..destination_number.."@page+flags{endconf"..moderator_flag.."}");
session:execute("conference", conf_name.."+flags{endconf"..moderator_flag.."}");
else
session:execute("playback", "tone_stream://%(500,500,480,620);loops=3");
end