//[LMAuthorize(LMRoles.LM_VIEW)] public IHttpActionResult RequestMonitorEnd(MonitorRequestArgs args) { try { if (ModelState.IsValid) { // Send end request if there are no active listeners on that call. if (AudioHandler.GetActiveListenerCt(args.CallId) < 1) { MailmanResponse mailmanResponse = CircuitsInterop.MonitorRequestEnd(args.CallId, args.LineId, args.UnitId, args.Ani); UInt32 responseCode = CircuitsInterop.GetResponseCode(mailmanResponse); //CircuitsInterop.MonitorRequestEnd(args.CallId, args.LineId, args.UnitId, args.Ani, false); //UInt32 responseCode = ResponseCodes.LM_OK; _logger.LogInfo($"Sent monitor end request for call ID: {args.CallId}"); IHttpActionResult result; switch (responseCode) { case ResponseCodes.LM_OK: case ResponseCodes.LM_NO_MONITORING_SESSION: // Monitor session already ended return(Ok()); case ResponseCodes.LM_INVALID_INFO: case ResponseCodes.LM_MONITOR_REQ_INVALID: result = BadRequest(); break; case ResponseCodes.LM_INTERNAL_ERROR: case ResponseCodes.LM_COMM_FAILURE: case ResponseCodes.LM_NOT_REGISTERED: result = InternalServerError(); break; default: result = InternalServerError(); break; } // Reaching this point means ResponseCode was something other than OK _logger.LogWarning($"Request Monitor End returned response code: {responseCode}\r\n\targs: {JsonConvert.SerializeObject(args)}"); return(result); } return(Ok()); } return(BadRequest(ModelState)); } catch (Exception ex) { _logger.LogError(ex, "Error sending call monitoring request"); return(InternalServerError(ex)); } }