diff --git a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua index 90a9909417..5049b064ba 100644 --- a/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua +++ b/app/scripts/resources/scripts/app/xml_handler/resources/scripts/dialplan/dialplan.lua @@ -116,10 +116,12 @@ --get the dialplan xml if (context_name == 'public' and dialplan_mode == 'single') then - sql = "SELECT (select domain_name from v_domains where domain_uuid = p.domain_uuid) as domain_name, dialplan_xml FROM v_dialplans AS p "; + sql = "SELECT (SELECT domain_name FROM v_domains WHERE domain_uuid = p.domain_uuid) as domain_name, " + sql = sql .. "(SELECT domain_enabled FROM v_domains WHERE domain_uuid = p.domain_uuid) as domain_enabled, p.dialplan_xml "; + sql = sql .. "FROM v_dialplans AS p "; sql = sql .. "WHERE ( "; sql = sql .. " p.dialplan_uuid IN ( "; - sql = sql .. " SELECT dialplan_uuid FROM v_destinations " + sql = sql .. " SELECT dialplan_uuid FROM v_destinations "; sql = sql .. " WHERE ( "; sql = sql .. " destination_prefix || destination_area_code || destination_number = :destination_number "; sql = sql .. " OR destination_trunk_prefix || destination_area_code || destination_number = :destination_number "; @@ -139,15 +141,17 @@ if (debug["sql"]) then freeswitch.consoleLog("notice", "[dialplan] SQL: " .. sql .. "; params:" .. json.encode(params) .. "\n"); end - local found = false; dbh:query(sql, params, function(row) if (row.domain_uuid ~= nil) then domain_name = row.domain_name; + else + table.insert(xml, row.dialplan_xml); + end + if (row.domain_enabled == true) then + table.insert(xml, row.dialplan_xml); end - table.insert(xml, row.dialplan_xml); - found = true; end); - if (not found) then + if (xml == nil) then table.insert(xml, [[ ]]); table.insert(xml, [[ ]]); table.insert(xml, [[ ]]);