Fix the dial_string.lua so that it uses the voicemail password from v_voicemails table, and have it clear the cached extension from memcache.
This commit is contained in:
@@ -50,6 +50,7 @@ if ( session:ready() ) then
|
|||||||
sip_from_host = session:getVariable("sip_from_host");
|
sip_from_host = session:getVariable("sip_from_host");
|
||||||
direction = session:getVariable("direction"); --in, out, both
|
direction = session:getVariable("direction"); --in, out, both
|
||||||
extension = tostring(session:getVariable("extension")); --true, false
|
extension = tostring(session:getVariable("extension")); --true, false
|
||||||
|
context = session:getVariable("context");
|
||||||
dial_string = tostring(session:getVariable("dial_string"));
|
dial_string = tostring(session:getVariable("dial_string"));
|
||||||
if (dial_string == "nil") then dial_string = ""; end
|
if (dial_string == "nil") then dial_string = ""; end
|
||||||
|
|
||||||
@@ -96,30 +97,43 @@ if ( session:ready() ) then
|
|||||||
else
|
else
|
||||||
sql = sql .. "AND e.unique_id = '" .. unique_id .."' ";
|
sql = sql .. "AND e.unique_id = '" .. unique_id .."' ";
|
||||||
end
|
end
|
||||||
if (pin_number) then
|
|
||||||
--do nothing
|
|
||||||
else
|
|
||||||
sql = sql .. "AND e.vm_password = '" .. vm_password .."' ";
|
|
||||||
end
|
|
||||||
if (debug["sql"]) then
|
if (debug["sql"]) then
|
||||||
freeswitch.consoleLog("NOTICE", "sql: ".. sql .. "\n");
|
freeswitch.consoleLog("NOTICE", "sql: ".. sql .. "\n");
|
||||||
end
|
end
|
||||||
dbh:query(sql, function(row)
|
dbh:query(sql, function(row)
|
||||||
db_domain_uuid = row.domain_uuid;
|
db_domain_uuid = row.domain_uuid;
|
||||||
db_extension_uuid = row.extension_uuid;
|
db_extension_uuid = row.extension_uuid;
|
||||||
|
db_extension = row.extension;
|
||||||
|
db_number_alias = row.number_alias;
|
||||||
db_dial_string = row.dial_string;
|
db_dial_string = row.dial_string;
|
||||||
db_dial_user = row.dial_user;
|
db_dial_user = row.dial_user;
|
||||||
db_dial_domain = row.dial_domain;
|
db_dial_domain = row.dial_domain;
|
||||||
end);
|
end);
|
||||||
|
|
||||||
--check to see if the pin number is correct
|
--check to see if the pin number is correct
|
||||||
if (pin_number) then
|
if (pin_number) then
|
||||||
if (pin_number ~= caller_pin_number) then
|
if (pin_number ~= caller_pin_number) then
|
||||||
--access denied
|
--access denied
|
||||||
db_extension_uuid = "";
|
db_extension_uuid = "";
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
sql = "SELECT * FROM v_voicemails ";
|
||||||
|
sql = sql .. "WHERE domain_uuid = '" .. db_domain_uuid .."' ";
|
||||||
|
if (tonumber(db_extension) == nil) then
|
||||||
|
sql = sql .. "AND voicemail_id = '" .. db_number_alias .."' ";
|
||||||
|
else
|
||||||
|
sql = sql .. "AND voicemail_id = '" .. db_extension .."' ";
|
||||||
|
end
|
||||||
|
dbh:query(sql, function(row)
|
||||||
|
voicemail_password = row.voicemail_password;
|
||||||
|
end);
|
||||||
|
if (voicemail_password ~= caller_pin_number) then
|
||||||
|
--access denied
|
||||||
|
db_extension_uuid = "";
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--process the request
|
||||||
if (string.len(db_extension_uuid) > 0) then
|
if (string.len(db_extension_uuid) > 0) then
|
||||||
--add the dial string
|
--add the dial string
|
||||||
if (direction == "in") then
|
if (direction == "in") then
|
||||||
@@ -182,6 +196,8 @@ if ( session:ready() ) then
|
|||||||
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-saved.wav");
|
session:streamFile(sounds_dir.."/"..default_language.."/"..default_dialect.."/"..default_voice.."/voicemail/vm-saved.wav");
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
--clear the cache
|
||||||
|
session:execute("memcache", "delete directory:"..db_extension.."@"..context);
|
||||||
else
|
else
|
||||||
session:streamFile("phrase:voicemail_fail_auth:#");
|
session:streamFile("phrase:voicemail_fail_auth:#");
|
||||||
session:hangup("NORMAL_CLEARING");
|
session:hangup("NORMAL_CLEARING");
|
||||||
|
|||||||
Reference in New Issue
Block a user