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);