Continue work to make IVR menu work from XML handler.
This commit is contained in:
parent
2c22aea566
commit
451b106c1e
|
|
@ -24,6 +24,9 @@
|
|||
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
-- POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--get the ivr name
|
||||
ivr_menu_uuid = params:getHeader("Menu-Name");
|
||||
|
||||
--get the cache
|
||||
hostname = trim(api:execute("switchname", ""));
|
||||
if (trim(api:execute("module_exists", "mod_memcache")) == "true") then
|
||||
|
|
@ -33,8 +36,7 @@
|
|||
end
|
||||
|
||||
--set the cache
|
||||
if (XML_STRING == "-ERR NOT FOUND") or (XML_STRING == "-ERR CONNECTION FAILURE") then
|
||||
|
||||
if (XML_STRING == "-ERR NOT FOUND" or XML_STRING == "-ERR CONNECTION FAILURE") then
|
||||
--connect to the database
|
||||
require "resources.functions.database_handle";
|
||||
dbh = database_handle('system');
|
||||
|
|
@ -49,6 +51,7 @@
|
|||
if (debug["sql"]) then
|
||||
freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n");
|
||||
end
|
||||
|
||||
status = dbh:query(sql, function(row)
|
||||
domain_uuid = row["domain_uuid"];
|
||||
ivr_menu_name = row["ivr_menu_name"];
|
||||
|
|
@ -69,7 +72,6 @@
|
|||
ivr_menu_max_failures = row["ivr_menu_max_failures"];
|
||||
ivr_menu_max_timeouts = row["ivr_menu_max_timeouts"];
|
||||
ivr_menu_digit_len = row["ivr_menu_digit_len"];
|
||||
|
||||
ivr_menu_direct_dial = row["ivr_menu_direct_dial"];
|
||||
ivr_menu_ringback = row["ivr_menu_ringback"];
|
||||
ivr_menu_cid_prefix = row["ivr_menu_cid_prefix"];
|
||||
|
|
@ -78,18 +80,13 @@
|
|||
|
||||
--recording path
|
||||
|
||||
|
||||
--start the xml array
|
||||
local xml = {}
|
||||
table.insert(xml, [[<?xml version="1.0" encoding="UTF-8" standalone="no"?>]]);
|
||||
table.insert(xml, [[<document type="freeswitch/xml">]]);
|
||||
table.insert(xml, [[ <section name="configuration">]]);
|
||||
table.insert(xml, [[ <configuration name="ivr.conf" description="IVR Menus">]]);
|
||||
|
||||
table.insert(xml, [[ <menus>]]);
|
||||
dbh:query(sql, function(row)
|
||||
|
||||
--build the xml
|
||||
table.insert(xml, [[ <menu name="]]..ivr_menu_uuid..[[" description="]]..ivr_menu_name..[[" ]]);
|
||||
table.insert(xml, [[ greet-long="]]..ivr_menu_greet_long..[[" ]]);
|
||||
table.insert(xml, [[ greet-short="]]..ivr_menu_greet_short..[[" ]]);
|
||||
|
|
@ -113,22 +110,20 @@
|
|||
freeswitch.consoleLog("notice", "[ivr_menu] SQL: " .. sql .. "\n");
|
||||
end
|
||||
status = dbh:query(sql, function(r)
|
||||
dbh:query(sql, function(r)
|
||||
ivr_menu_option_digits = r.ivr_menu_option_digits
|
||||
ivr_menu_option_action = r.ivr_menu_option_action
|
||||
ivr_menu_option_param = r.ivr_menu_option_param
|
||||
ivr_menu_option_description = row.ivr_menu_option_description
|
||||
table.insert(xml, [[<entry action="]]..ivr_menu_option_action..[[" digits="]]..ivr_menu_option_digits..[[" param="]]..ivr_menu_option_param..[["/><!--]]..ivr_menu_option_description..[[-->]]);
|
||||
end)
|
||||
end);
|
||||
|
||||
--direct dial
|
||||
if (ivr_menu_direct_dial == "true") then
|
||||
table.insert(xml, [[<entry action="menu-exec-app" digits="/(^(\d{2,5}))$/" param="transfer $1 XML features"/>\n");
|
||||
table.insert(xml, [[<entry action="menu-exec-app" digits="/(^(\d{2,5}))$/" param="transfer $1 XML features"/>\n]]);
|
||||
end
|
||||
end)
|
||||
table.insert(xml, [[ </menus>]]);
|
||||
|
||||
--close the extension tag if it was left open
|
||||
table.insert(xml, [[ </menus>]]);
|
||||
table.insert(xml, [[ </configuration>]]);
|
||||
table.insert(xml, [[ </section>]]);
|
||||
table.insert(xml, [[</document>]]);
|
||||
|
|
@ -155,6 +150,7 @@
|
|||
if (debug["cache"]) then
|
||||
freeswitch.consoleLog("notice", "[xml_handler] configuration:ivr.conf:" .. hostname .." source: database\n");
|
||||
end
|
||||
|
||||
else
|
||||
--replace the ' back to a single quote
|
||||
XML_STRING = XML_STRING:gsub("'", "'");
|
||||
|
|
|
|||
Loading…
Reference in New Issue