Rename ring_member.lua to destination.lua.
This commit is contained in:
+36
-26
@@ -38,20 +38,20 @@
|
|||||||
digit_timeout = "3000";
|
digit_timeout = "3000";
|
||||||
|
|
||||||
--define uuid function
|
--define uuid function
|
||||||
local random = math.random
|
local random = math.random;
|
||||||
local function uuid()
|
local function uuid();
|
||||||
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
|
local template ='xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
||||||
return string.gsub(template, '[xy]', function (c)
|
return string.gsub(template, '[xy]', function (c)
|
||||||
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb)
|
local v = (c == 'x') and random(0, 0xf) or random(8, 0xb);
|
||||||
return string.format('%x', v)
|
return string.format('%x', v);
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
--get session variables
|
--get session variables
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
session:answer();
|
session:answer();
|
||||||
--session:execute("info", "");
|
--session:execute("info", "");
|
||||||
destination_number = session:getVariable("user_name");
|
destination_number = session:getVariable("destination_number");
|
||||||
pin_number = session:getVariable("pin_number");
|
pin_number = session:getVariable("pin_number");
|
||||||
sounds_dir = session:getVariable("sounds_dir");
|
sounds_dir = session:getVariable("sounds_dir");
|
||||||
ring_group_uuid = session:getVariable("ring_group_uuid");
|
ring_group_uuid = session:getVariable("ring_group_uuid");
|
||||||
@@ -73,13 +73,26 @@
|
|||||||
ring_group_destination_uuid = uuid();
|
ring_group_destination_uuid = uuid();
|
||||||
end
|
end
|
||||||
|
|
||||||
--pin number is not required
|
--if the pin number is provided then require it
|
||||||
|
if (pin_number) then
|
||||||
|
min_digits = string.len(pin_number);
|
||||||
|
max_digits = string.len(pin_number)+1;
|
||||||
|
digits = session:playAndGetDigits(min_digits, max_digits, max_tries, digit_timeout, "#", sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-please_enter_pin_followed_by_pound.wav", "", "\\d+");
|
||||||
|
if (digits == pin_number) then
|
||||||
|
--pin is correct
|
||||||
|
else
|
||||||
|
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-pin_or_extension_is-invalid.wav");
|
||||||
|
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/ivr/ivr-im_sorry.wav");
|
||||||
|
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-goodbye.wav");
|
||||||
|
session:hangup("NORMAL_CLEARING");
|
||||||
|
return;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--press 1 to login and 2 to logout
|
--press 1 to login and 2 to logout
|
||||||
if (session:ready()) then
|
if (session:ready()) then
|
||||||
menu_selection = session:playAndGetDigits(1, 1, max_tries, digit_timeout, "#", "ivr/ivr-enter_destination_telephone_number.wav", "", "\\d+");
|
menu_selection = session:playAndGetDigits(1, 1, max_tries, digit_timeout, "#", "ivr/ivr-enter_destination_telephone_number.wav", "", "\\d+");
|
||||||
freeswitch.consoleLog("NOTICE", "menu_selection: "..menu_selection.."\n");
|
freeswitch.consoleLog("NOTICE", "[ring_group] menu_selection: "..menu_selection.."\n");
|
||||||
if (menu_selection == "1") then
|
if (menu_selection == "1") then
|
||||||
--first, check to see if the destination is already in this ring group
|
--first, check to see if the destination is already in this ring group
|
||||||
sql = [[
|
sql = [[
|
||||||
@@ -90,7 +103,7 @@
|
|||||||
AND ring_group_uuid = ']]..ring_group_uuid..[['
|
AND ring_group_uuid = ']]..ring_group_uuid..[['
|
||||||
AND destination_number = ']]..destination_number..[['
|
AND destination_number = ']]..destination_number..[['
|
||||||
]];
|
]];
|
||||||
--freeswitch.consoleLog("NOTICE", "ring_group_member: SQL "..sql.."\n");
|
--freeswitch.consoleLog("NOTICE", "[ring_group] SQL "..sql.."\n");
|
||||||
|
|
||||||
assert(dbh:query(sql, function(row)
|
assert(dbh:query(sql, function(row)
|
||||||
if (row.in_group == "0") then
|
if (row.in_group == "0") then
|
||||||
@@ -102,43 +115,40 @@
|
|||||||
ring_group_uuid,
|
ring_group_uuid,
|
||||||
destination_number,
|
destination_number,
|
||||||
destination_delay,
|
destination_delay,
|
||||||
destination_timeout)
|
destination_timeout
|
||||||
|
)
|
||||||
VALUES
|
VALUES
|
||||||
( ']]..ring_group_destination_uuid..[[',
|
( ']]..ring_group_destination_uuid..[[',
|
||||||
']]..domain_uuid..[[',
|
']]..domain_uuid..[[',
|
||||||
']]..ring_group_uuid..[[',
|
']]..ring_group_uuid..[[',
|
||||||
']]..destination_number..[[',
|
']]..destination_number..[[',
|
||||||
]]..destination_delay..[[,
|
]]..destination_delay..[[,
|
||||||
]]..destination_timeout..[[)
|
]]..destination_timeout..[[
|
||||||
|
)]];
|
||||||
]];
|
--freeswitch.consoleLog("NOTICE", "[ring_group][destination] SQL "..sql.."\n");
|
||||||
|
|
||||||
--freeswitch.consoleLog("NOTICE", "ring_group_member: SQL "..sql.."\n");
|
|
||||||
dbh:query(sql);
|
dbh:query(sql);
|
||||||
|
|
||||||
freeswitch.consoleLog("NOTICE", "ring_group_member: LOG IN\n");
|
freeswitch.consoleLog("NOTICE", "[ring_group][destination] LOG IN\n");
|
||||||
session:streamFile("ivr/ivr-you_are_now_logged_in.wav");
|
session:streamFile("ivr/ivr-you_are_now_logged_in.wav");
|
||||||
|
|
||||||
else
|
else
|
||||||
freeswitch.consoleLog("NOTICE", "ring_group_member: ALREADY LOGGED IN\n");
|
freeswitch.consoleLog("NOTICE", "[ring_group][destination] ALREADY LOGGED IN\n");
|
||||||
session:streamFile("ivr/ivr-you_are_now_logged_in.wav");
|
session:streamFile("ivr/ivr-you_are_now_logged_in.wav");
|
||||||
end
|
end
|
||||||
end));
|
end));
|
||||||
|
|
||||||
end
|
end
|
||||||
if (menu_selection == "2") then
|
if (menu_selection == "2") then
|
||||||
sql = [[
|
sql = [[
|
||||||
DELETE FROM
|
DELETE FROM
|
||||||
v_ring_group_destinations
|
v_ring_group_destinations
|
||||||
WHERE
|
WHERE
|
||||||
domain_uuid =']]..domain_uuid..[['
|
domain_uuid =']]..domain_uuid..[['
|
||||||
AND ring_group_uuid=']]..ring_group_uuid..[['
|
AND ring_group_uuid=']]..ring_group_uuid..[['
|
||||||
AND destination_number=']]..destination_number..[['
|
AND destination_number=']]..destination_number..[['
|
||||||
]];
|
]];
|
||||||
freeswitch.consoleLog("NOTICE", "ring_group_member: SQL "..sql.."\n");
|
freeswitch.consoleLog("NOTICE", "[ring_group][destination] SQL "..sql.."\n");
|
||||||
dbh:query(sql);
|
dbh:query(sql);
|
||||||
|
|
||||||
freeswitch.consoleLog("NOTICE", "ring_group_member: LOG OUT\n");
|
freeswitch.consoleLog("NOTICE", "[ring_group][destination] LOG OUT\n");
|
||||||
session:streamFile("ivr/ivr-you_are_now_logged_out.wav");
|
session:streamFile("ivr/ivr-you_are_now_logged_out.wav");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user