fix: update GetFeedbacksForDeviceRequestHandler to return JSON response for missing device

This commit is contained in:
Neil Dorin 2026-04-01 08:56:10 -06:00
parent 305a466b1b
commit 1b10910cc2

View file

@ -1,13 +1,14 @@
using System.Linq; using System;
using System.Linq;
using Crestron.SimplSharp.WebScripting; using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core.Web.RequestHandlers; using PepperDash.Core.Web.RequestHandlers;
namespace PepperDash.Essentials.Core.Web.RequestHandlers namespace PepperDash.Essentials.Core.Web.RequestHandlers
{ {
/// <summary> /// <summary>
/// Represents a GetFeedbacksForDeviceRequestHandler /// Represents a GetFeedbacksForDeviceRequestHandler
/// </summary> /// </summary>
public class GetFeedbacksForDeviceRequestHandler : WebApiBaseRequestHandler public class GetFeedbacksForDeviceRequestHandler : WebApiBaseRequestHandler
{ {
/// <summary> /// <summary>
@ -51,8 +52,20 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
var device = DeviceManager.GetDeviceForKey(deviceObj.ToString()) as IHasFeedback; var device = DeviceManager.GetDeviceForKey(deviceObj.ToString()) as IHasFeedback;
if (device == null) if (device == null)
{ {
context.Response.StatusCode = 404; context.Response.StatusCode = 200;
context.Response.StatusDescription = "Not Found"; context.Response.StatusDescription = "OK";
context.Response.ContentType = "application/json";
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
var resp = new
{
BoolValues = Array.Empty<object>(),
IntValues = Array.Empty<object>(),
SerialValues = Array.Empty<object>()
};
var respJs = JsonConvert.SerializeObject(resp, Formatting.Indented);
context.Response.Write(respJs, false);
context.Response.End(); context.Response.End();
return; return;