diff --git a/includes/install/scripts/xml_handler.lua b/includes/install/scripts/xml_handler.lua index 4d7a357a2d..dfd70545e9 100644 --- a/includes/install/scripts/xml_handler.lua +++ b/includes/install/scripts/xml_handler.lua @@ -80,74 +80,83 @@ --handle the directory if (XML_REQUEST["section"] == "directory" and key and user and domain_name) then - --get the extension from the database - sql = "SELECT * FROM v_extensions WHERE domain_uuid = '" .. domain_uuid .. "' and extension = '" .. user .. "' and enabled = 'true' "; - if (debug["sql"]) then - freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); - end - dbh:query(sql, function(row) - --general - domain_uuid = row.domain_uuid; - extension = row.extension; - cidr = ""; - if (string.len(row.cidr) > 0) then - cidr = [[ cidr="]] .. row.cidr .. [["]]; - end - number_alias = ""; - if (string.len(row.number_alias) > 0) then - number_alias = [[ number-alias="]] .. row.number_alias .. [["]]; - end - --params - password = row.password; - vm_enabled = "true"; - if (string.len(row.vm_enabled) > 0) then - vm_enabled = row.vm_enabled; - end - vm_password = row.vm_password; - vm_attach_file = "true"; - if (string.len(row.vm_attach_file) > 0) then - vm_attach_file = row.vm_attach_file; - end - vm_keep_local_after_email = "true"; - if (string.len(row.vm_keep_local_after_email) > 0) then - vm_keep_local_after_email = row.vm_keep_local_after_email; - end - if (string.len(row.vm_mailto) > 0) then - vm_mailto = row.vm_mailto; - else - vm_mailto = ""; - end - mwi_account = row.mwi_account; - auth_acl = row.auth_acl; - --variables - sip_from_user = row.extension; - call_group = row.call_group; - hold_music = row.hold_music; - toll_allow = row.toll_allow; - accountcode = row.accountcode; - user_context = row.user_context; - effective_caller_id_name = row.effective_caller_id_name; - effective_caller_id_number = row.effective_caller_id_number; - outbound_caller_id_name = row.outbound_caller_id_name; - outbound_caller_id_number = row.outbound_caller_id_number; - emergency_caller_id_number = row.emergency_caller_id_number; - directory_full_name = row.directory_full_name; - directory_visible = row.directory_visible; - directory_exten_visible = row.directory_exten_visible; - limit_max = row.limit_max; - limit_destination = row.limit_destination; - sip_force_contact = row.sip_force_contact; - sip_force_expires = row.sip_force_expires; - nibble_account = row.nibble_account; - sip_bypass_media = row.sip_bypass_media; - --set the dial_string - if (string.len(row.dial_string) > 0) then - dial_string = row.dial_string; - else - dial_string = "{sip_invite_domain=${domain_name},presence_id=${dialed_user}@${domain_name}}${sofia_contact(${dialed_user}@${domain_name})}"; - end - end); + --prevent processing for invalid user + continue = true; + if (user == "*97") then + continue = false; + end + + --get the extension from the database + if (continue) then + sql = "SELECT * FROM v_extensions WHERE domain_uuid = '" .. domain_uuid .. "' and extension = '" .. user .. "' and enabled = 'true' "; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[xml_handler] SQL: " .. sql .. "\n"); + end + dbh:query(sql, function(row) + --general + domain_uuid = row.domain_uuid; + extension = row.extension; + cidr = ""; + if (string.len(row.cidr) > 0) then + cidr = [[ cidr="]] .. row.cidr .. [["]]; + end + number_alias = ""; + if (string.len(row.number_alias) > 0) then + number_alias = [[ number-alias="]] .. row.number_alias .. [["]]; + end + --params + password = row.password; + vm_enabled = "true"; + if (string.len(row.vm_enabled) > 0) then + vm_enabled = row.vm_enabled; + end + vm_password = row.vm_password; + vm_attach_file = "true"; + if (string.len(row.vm_attach_file) > 0) then + vm_attach_file = row.vm_attach_file; + end + vm_keep_local_after_email = "true"; + if (string.len(row.vm_keep_local_after_email) > 0) then + vm_keep_local_after_email = row.vm_keep_local_after_email; + end + if (string.len(row.vm_mailto) > 0) then + vm_mailto = row.vm_mailto; + else + vm_mailto = ""; + end + mwi_account = row.mwi_account; + auth_acl = row.auth_acl; + --variables + sip_from_user = row.extension; + call_group = row.call_group; + hold_music = row.hold_music; + toll_allow = row.toll_allow; + accountcode = row.accountcode; + user_context = row.user_context; + effective_caller_id_name = row.effective_caller_id_name; + effective_caller_id_number = row.effective_caller_id_number; + outbound_caller_id_name = row.outbound_caller_id_name; + outbound_caller_id_number = row.outbound_caller_id_number; + emergency_caller_id_number = row.emergency_caller_id_number; + directory_full_name = row.directory_full_name; + directory_visible = row.directory_visible; + directory_exten_visible = row.directory_exten_visible; + limit_max = row.limit_max; + limit_destination = row.limit_destination; + sip_force_contact = row.sip_force_contact; + sip_force_expires = row.sip_force_expires; + nibble_account = row.nibble_account; + sip_bypass_media = row.sip_bypass_media; + + --set the dial_string + if (string.len(row.dial_string) > 0) then + dial_string = row.dial_string; + else + dial_string = "{sip_invite_domain=" .. domain_name .. ",presence_id=" .. user .. "@" .. domain_name .. "}${sofia_contact(" .. user .. "@" .. domain_name .. ")}"; + end + end); + end --outbound hot desking - get the extension variables sql = "SELECT * FROM v_extensions WHERE dial_domain = '" .. domain_name .. "' and dial_user = '" .. user .. "' and enabled = 'true' "; @@ -156,6 +165,7 @@ end dbh:query(sql, function(row) --variables + extension_uuid = row.extension_uuid; domain_uuid = row.domain_uuid; sip_from_user = row.extension; call_group = row.call_group; @@ -188,15 +198,15 @@ 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 - table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); else - table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); end end table.insert(xml, [[ ]]); @@ -401,7 +411,7 @@ --open the tags if (dialplan_tag_status == "closed") then - table.insert(xml, [[ ]]); + table.insert(xml, [[ ]]); dialplan_tag_status = "open"; end if (dialplan_detail_tag == "condition") then @@ -513,7 +523,7 @@ --send the xml to the console if (debug["xml_string"]) then - local file = assert(io.open("/tmp/dialplan.xml", "w")); + local file = assert(io.open("/tmp/dialplan-" .. call_context .. ".xml", "w")); file:write(XML_STRING); file:close(); end