瀏覽代碼

Use GeneralCommandType in SessionController parameters

Niels van Velzen 4 年之前
父節點
當前提交
891c538f81
共有 1 個文件被更改,包括 4 次插入14 次删除
  1. 4 14
      Jellyfin.Api/Controllers/SessionController.cs

+ 4 - 14
Jellyfin.Api/Controllers/SessionController.cs

@@ -215,17 +215,12 @@ namespace Jellyfin.Api.Controllers
         [ProducesResponseType(StatusCodes.Status204NoContent)]
         [ProducesResponseType(StatusCodes.Status204NoContent)]
         public ActionResult SendSystemCommand(
         public ActionResult SendSystemCommand(
             [FromRoute, Required] string sessionId,
             [FromRoute, Required] string sessionId,
-            [FromRoute, Required] string command)
+            [FromRoute, Required] GeneralCommandType command)
         {
         {
-            if (!Enum.TryParse(command, true, out GeneralCommandType commandType))
-            {
-                return BadRequest();
-            }
-
             var currentSession = RequestHelpers.GetSession(_sessionManager, _authContext, Request);
             var currentSession = RequestHelpers.GetSession(_sessionManager, _authContext, Request);
             var generalCommand = new GeneralCommand
             var generalCommand = new GeneralCommand
             {
             {
-                Name = commandType,
+                Name = command,
                 ControllingUserId = currentSession.UserId
                 ControllingUserId = currentSession.UserId
             };
             };
 
 
@@ -246,18 +241,13 @@ namespace Jellyfin.Api.Controllers
         [ProducesResponseType(StatusCodes.Status204NoContent)]
         [ProducesResponseType(StatusCodes.Status204NoContent)]
         public ActionResult SendGeneralCommand(
         public ActionResult SendGeneralCommand(
             [FromRoute, Required] string sessionId,
             [FromRoute, Required] string sessionId,
-            [FromRoute, Required] string command)
+            [FromRoute, Required] GeneralCommandType command)
         {
         {
-            if (!Enum.TryParse(command, true, out GeneralCommandType commandType))
-            {
-                return BadRequest();
-            }
-
             var currentSession = RequestHelpers.GetSession(_sessionManager, _authContext, Request);
             var currentSession = RequestHelpers.GetSession(_sessionManager, _authContext, Request);
 
 
             var generalCommand = new GeneralCommand
             var generalCommand = new GeneralCommand
             {
             {
-                Name = commandType,
+                Name = command,
                 ControllingUserId = currentSession.UserId
                 ControllingUserId = currentSession.UserId
             };
             };