diff --git a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua index 82582e5d14..b0528eb9f1 100644 --- a/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua +++ b/resources/install/scripts/app/xml_handler/resources/scripts/directory/directory.lua @@ -195,8 +195,10 @@ cidr = [[ cidr="]] .. row.cidr .. [["]]; end number_alias = ""; + number_alias_string = ""; if (string.len(row.number_alias) > 0) then - number_alias = [[ number-alias="]] .. row.number_alias .. [["]]; + number_alias = row.number_alias; + number_alias_string = [[ number-alias="]] .. row.number_alias .. [["]]; end --params password = row.password; @@ -259,12 +261,16 @@ --get the voicemail from the database if (continue) then - sql = "SELECT * FROM v_voicemails WHERE domain_uuid = '" .. domain_uuid .. "' and voicemail_id = '" .. user .. "' "; + vm_enabled = "true"; + if (tonumber(user) == nil) then + sql = "SELECT * FROM v_voicemails WHERE domain_uuid = '" .. domain_uuid .. "' and voicemail_id = '" .. number_alias .. "' "; + else + sql = "SELECT * FROM v_voicemails WHERE domain_uuid = '" .. domain_uuid .. "' and voicemail_id = '" .. user .. "' "; + end if (debug["sql"]) then freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); end dbh:query(sql, function(row) - vm_enabled = "true"; if (string.len(row.voicemail_enabled) > 0) then vm_enabled = row.voicemail_enabled; end @@ -339,9 +345,9 @@ table.insert(xml, [[ ]]); if (number_alias) then if (cidr) then - table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); else - table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); end else if (cidr) then @@ -509,4 +515,4 @@ --send the xml to the console if (debug["xml_string"]) then freeswitch.consoleLog("notice", "[xml_handler] XML_STRING: \n" .. XML_STRING .. "\n"); - end + end \ No newline at end of file