diff --git a/html/includes/api_functions.inc.php b/html/includes/api_functions.inc.php index 7141e7bbce..37bf96d981 100644 --- a/html/includes/api_functions.inc.php +++ b/html/includes/api_functions.inc.php @@ -795,7 +795,39 @@ function ack_alert() { $app->response->setStatus($code); $app->response->headers->set('Content-Type', 'application/json'); echo _json_encode($output); +} +function unmute_alert() { + global $config; + $app = \Slim\Slim::getInstance(); + $router = $app->router()->getCurrentRoute()->getParams(); + $alert_id = mres($router['id']); + $status = 'error'; + $err_msg = ''; + $message = ''; + $code = 500; + if (is_numeric($alert_id)) { + $status = 'ok'; + $code = 200; + if (dbUpdate(array('state' => 1), 'alerts', '`id` = ? LIMIT 1', array($alert_id))) { + $message = 'Alert has been unmuted'; + } + else { + $message = 'No alert by that ID'; + } + } + else { + $err_msg = 'Invalid alert has been provided'; + } + + $output = array( + 'status' => $status, + 'err-msg' => $err_msg, + 'message' => $message, + ); + $app->response->setStatus($code); + $app->response->headers->set('Content-Type', 'application/json'); + echo _json_encode($output); }