Fix. Allow multiple actions in IVR

This commit is contained in:
Alexey Melnichuk 2016-02-04 19:05:24 +03:00
parent 1f9fbc6b7b
commit a9e4f5a3e6
1 changed files with 14 additions and 10 deletions

View File

@ -314,7 +314,7 @@
log.notice("SQL: " .. sql); log.notice("SQL: " .. sql);
end end
local action, script, data local actions, script, data = {}
dbh:query(sql, function(row) dbh:query(sql, function(row)
-- clear vars -- clear vars
action, script, data = nil action, script, data = nil
@ -361,7 +361,8 @@
-- break loop -- break loop
if action and #action > 0 then if action and #action > 0 then
return 1 actions[#actions + 1] = {action, script, data}
return
end end
-- we have unsupported IVR action -- we have unsupported IVR action
@ -369,7 +370,9 @@
end); --end results end); --end results
--execute --execute
if action and #action > 0 then if #actions > 0 then
for _, t in ipairs(actions) do
local action, script, data = t[1],t[2],t[3]
-- send to the log -- send to the log
if (debug["action"]) then if (debug["action"]) then
log.notice("action: " .. action .. " data: ".. data); log.notice("action: " .. action .. " data: ".. data);
@ -378,14 +381,15 @@
-- run the action (with return to menu) -- run the action (with return to menu)
if action == 'phrase' or script == 'streamfile.lua' then if action == 'phrase' or script == 'streamfile.lua' then
session:execute(action, data); session:execute(action, data);
return menu(); else
if ivr_menu_exit_sound and #ivr_menu_exit_sound > 0 then
session:streamFile(ivr_menu_exit_sound);
end
-- run the action (without return to menu)
return session:execute(action, data);
end end
end
-- run the action (without return to menu) return menu();
if ivr_menu_exit_sound and #ivr_menu_exit_sound > 0 then
session:streamFile(ivr_menu_exit_sound);
end
return session:execute(action, data);
end end
--direct dial --direct dial