From 06ed8f2998dcc3e6a513a6ecdc53b8c9b12e45c3 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 5 Sep 2015 10:05:43 -0600 Subject: [PATCH] When *78 or *79 are used for DND update the user status and agent status. --- resources/install/scripts/do_not_disturb.lua | 31 ++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/resources/install/scripts/do_not_disturb.lua b/resources/install/scripts/do_not_disturb.lua index 8e067860af..97af20b2c4 100644 --- a/resources/install/scripts/do_not_disturb.lua +++ b/resources/install/scripts/do_not_disturb.lua @@ -142,6 +142,37 @@ end dbh:query(sql); + --determine whether to update the dial string + sql = "select * from v_extension_users as e, v_users as u "; + sql = sql .. "where e.extension_uuid = '"..extension_uuid.."' "; + sql = sql .. "and e.user_uuid = u.user_uuid "; + sql = sql .. "and e.domain_uuid = '"..domain_uuid.."' "; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n"); + end + status = dbh:query(sql, function(row) + --update the call center status + if (enabled == "true") then + user_status = "Logged Out"; + api:execute("callcenter_config", "agent set status "..row.username.."@"..domain_name.." '"..user_status.."'"); + end + + --update the database user_status + if (enabled == "true") then + user_status = "Do Not Disturb"; + else + user_status = "Available"; + end + sql = sql .. "update v_users set "; + sql = sql .. "user_status = '"..user_status.."' "; + sql = sql .. "where domain_uuid = '"..domain_uuid.."' "; + sql = sql .. "and username = '"..row.user_uuid.."' "; + if (debug["sql"]) then + freeswitch.consoleLog("notice", "[do_not_disturb] "..sql.."\n"); + end + dbh:query(sql); + end); + --clear the cache if (extension ~= nil) then api:execute("memcache", "delete directory:"..extension.."@"..domain_name);