Update page.lua
Update page.lua add support for rtp_secure_media=true.
This commit is contained in:
@@ -58,6 +58,7 @@
|
|||||||
domain_name = session:getVariable("domain_name");
|
domain_name = session:getVariable("domain_name");
|
||||||
sounds_dir = session:getVariable("sounds_dir");
|
sounds_dir = session:getVariable("sounds_dir");
|
||||||
destinations = session:getVariable("destinations");
|
destinations = session:getVariable("destinations");
|
||||||
|
rtp_secure_media = session:getVariable("rtp_secure_media");
|
||||||
if (destinations == nil) then
|
if (destinations == nil) then
|
||||||
destinations = session:getVariable("extension_list");
|
destinations = session:getVariable("extension_list");
|
||||||
end
|
end
|
||||||
@@ -75,122 +76,130 @@
|
|||||||
if (not default_dialect) then default_dialect = 'us'; end
|
if (not default_dialect) then default_dialect = 'us'; end
|
||||||
if (not default_voice) then default_voice = 'callie'; end
|
if (not default_voice) then default_voice = 'callie'; end
|
||||||
|
|
||||||
local conference_name = "page-"..destination_number.."-"..domain_name.."@page"
|
--set rtp_secure_media to an empty string if not provided.
|
||||||
|
if (rtp_secure_media == nil) then
|
||||||
|
rtp_secure_media = 'false';
|
||||||
|
end
|
||||||
|
|
||||||
if (caller_id_name) then
|
--define the conference name
|
||||||
--caller id name provided do nothing
|
local conference_name = "page-"..destination_number.."-"..domain_name.."@page"
|
||||||
else
|
|
||||||
effective_caller_id_name = session:getVariable("effective_caller_id_name");
|
|
||||||
caller_id_name = effective_caller_id_name;
|
|
||||||
end
|
|
||||||
|
|
||||||
if (caller_id_number) then
|
--set the caller id
|
||||||
--caller id number provided do nothing
|
if (caller_id_name) then
|
||||||
else
|
--caller id name provided do nothing
|
||||||
effective_caller_id_number = session:getVariable("effective_caller_id_number");
|
else
|
||||||
caller_id_number = effective_caller_id_number;
|
effective_caller_id_name = session:getVariable("effective_caller_id_name");
|
||||||
end
|
caller_id_name = effective_caller_id_name;
|
||||||
|
end
|
||||||
|
|
||||||
|
if (caller_id_number) then
|
||||||
|
--caller id number provided do nothing
|
||||||
|
else
|
||||||
|
effective_caller_id_number = session:getVariable("effective_caller_id_number");
|
||||||
|
caller_id_number = effective_caller_id_number;
|
||||||
|
end
|
||||||
|
|
||||||
--set conference flags
|
--set conference flags
|
||||||
if (mute == "true") then
|
if (mute == "true") then
|
||||||
flags = "flags{mute}";
|
flags = "flags{mute}";
|
||||||
else
|
else
|
||||||
flags = "flags{}";
|
flags = "flags{}";
|
||||||
end
|
end
|
||||||
|
|
||||||
--if the pin number is provided then require it
|
--if the pin number is provided then require it
|
||||||
if (pin_number) then
|
if (pin_number) then
|
||||||
--sleep
|
--sleep
|
||||||
session:sleep(500);
|
session:sleep(500);
|
||||||
--get the user pin number
|
--get the user pin number
|
||||||
min_digits = 2;
|
min_digits = 2;
|
||||||
max_digits = 20;
|
max_digits = 20;
|
||||||
digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
|
digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", "phrase:voicemail_enter_pass:#", "", "\\d+");
|
||||||
--validate the user pin number
|
--validate the user pin number
|
||||||
pin_number_table = explode(",",pin_number);
|
pin_number_table = explode(",",pin_number);
|
||||||
for index,pin_number in pairs(pin_number_table) do
|
for index,pin_number in pairs(pin_number_table) do
|
||||||
if (digits == pin_number) then
|
if (digits == pin_number) then
|
||||||
--set the variable to true
|
--set the variable to true
|
||||||
auth = true;
|
auth = true;
|
||||||
--set the authorized pin number that was used
|
--set the authorized pin number that was used
|
||||||
session:setVariable("pin_number", pin_number);
|
session:setVariable("pin_number", pin_number);
|
||||||
--end the loop
|
--end the loop
|
||||||
break;
|
break;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
--if not authorized play a message and then hangup
|
||||||
|
if (not auth) then
|
||||||
|
session:streamFile("phrase:voicemail_fail_auth:#");
|
||||||
|
session:hangup("NORMAL_CLEARING");
|
||||||
|
return;
|
||||||
end
|
end
|
||||||
end
|
|
||||||
--if not authorized play a message and then hangup
|
|
||||||
if (not auth) then
|
|
||||||
session:streamFile("phrase:voicemail_fail_auth:#");
|
|
||||||
session:hangup("NORMAL_CLEARING");
|
|
||||||
return;
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
destination_count = 0;
|
|
||||||
api = freeswitch.API();
|
|
||||||
for index,value in pairs(destination_table) do
|
|
||||||
if (string.find(value, "-") == nil) then
|
|
||||||
value = value..'-'..value;
|
|
||||||
end
|
end
|
||||||
sub_table = explode("-",value);
|
|
||||||
zeros = leading_zeros(sub_table[1]);
|
|
||||||
for destination=sub_table[1],sub_table[2] do
|
|
||||||
|
|
||||||
--add the leading zeros back again
|
--originate the calls
|
||||||
destination = zeros .. destination;
|
destination_count = 0;
|
||||||
|
api = freeswitch.API();
|
||||||
|
for index,value in pairs(destination_table) do
|
||||||
|
if (string.find(value, "-") == nil) then
|
||||||
|
value = value..'-'..value;
|
||||||
|
end
|
||||||
|
sub_table = explode("-",value);
|
||||||
|
zeros = leading_zeros(sub_table[1]);
|
||||||
|
for destination=sub_table[1],sub_table[2] do
|
||||||
|
|
||||||
--get the destination required for number-alias
|
--add the leading zeros back again
|
||||||
destination = api:execute("user_data", destination .. "@" .. domain_name .. " attr id");
|
destination = zeros .. destination;
|
||||||
|
|
||||||
--prevent calling the user that initiated the page
|
--get the destination required for number-alias
|
||||||
if (sip_from_user ~= destination) then
|
destination = api:execute("user_data", destination .. "@" .. domain_name .. " attr id");
|
||||||
--cmd = "username_exists id "..destination.."@"..domain_name;
|
|
||||||
--reply = trim(api:executeString(cmd));
|
--prevent calling the user that initiated the page
|
||||||
--if (reply == "true") then
|
if (sip_from_user ~= destination) then
|
||||||
destination_status = "show channels like "..destination.."@";
|
--cmd = "username_exists id "..destination.."@"..domain_name;
|
||||||
reply = trim(api:executeString(destination_status));
|
--reply = trim(api:executeString(cmd));
|
||||||
if (reply == "0 total.") then
|
--if (reply == "true") then
|
||||||
freeswitch.consoleLog("NOTICE", "[page] destination "..destination.." available\n");
|
destination_status = "show channels like "..destination.."@";
|
||||||
if (destination == tonumber(sip_from_user)) then
|
reply = trim(api:executeString(destination_status));
|
||||||
--this destination is the caller that initated the page
|
if (reply == "0 total.") then
|
||||||
else
|
freeswitch.consoleLog("NOTICE", "[page] destination "..destination.." available\n");
|
||||||
--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:"..conference_name.."+"..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
|
if (destination == tonumber(sip_from_user)) then
|
||||||
--this destination is the caller that initated the page
|
--this destination is the caller that initated the page
|
||||||
else
|
else
|
||||||
--originate the call
|
--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:"..conference_name.."+"..flags.." inline";
|
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_name.."+"..flags.." inline";
|
||||||
api:executeString(cmd_string);
|
api:executeString(cmd_string);
|
||||||
destination_count = destination_count + 1;
|
destination_count = destination_count + 1;
|
||||||
end
|
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,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_name.."+"..flags.." inline";
|
||||||
|
api:executeString(cmd_string);
|
||||||
|
destination_count = destination_count + 1;
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
--end
|
||||||
--end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
--send main call to the conference room
|
--send main call to the conference room
|
||||||
if (destination_count > 0) then
|
if (destination_count > 0) then
|
||||||
if (session:getVariable("moderator") == "true") then
|
if (session:getVariable("moderator") == "true") then
|
||||||
moderator_flag = ",moderator";
|
moderator_flag = ",moderator";
|
||||||
|
else
|
||||||
|
moderator_flag = "";
|
||||||
|
end
|
||||||
|
session:execute("conference", conference_name.."+flags{endconf"..moderator_flag.."}");
|
||||||
else
|
else
|
||||||
moderator_flag = "";
|
session:execute("playback", "tone_stream://%(500,500,480,620);loops=3");
|
||||||
end
|
end
|
||||||
session:execute("conference", conference_name.."+flags{endconf"..moderator_flag.."}");
|
|
||||||
else
|
|
||||||
session:execute("playback", "tone_stream://%(500,500,480,620);loops=3");
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user