From 63c8c5bc9d893ac1b25ef06e8ab0bdabc738655d Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 15 Jan 2019 17:22:47 +0000 Subject: [PATCH] fixes some error messages responses --- .../Controllers/Communicating/LiveController.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Yavsc/Controllers/Communicating/LiveController.cs b/src/Yavsc/Controllers/Communicating/LiveController.cs index 1c051912..a732e666 100644 --- a/src/Yavsc/Controllers/Communicating/LiveController.cs +++ b/src/Yavsc/Controllers/Communicating/LiveController.cs @@ -66,10 +66,20 @@ namespace Yavsc.Controllers.Communicating var uname = User.GetUserName(); // ensure uniqueness of casting stream from this user var existent = Casters[uname]; - if (existent != null) return new BadRequestObjectResult("not supported, you already casting, there's support for one live streaming only"); + if (existent != null) + { + ModelState.AddModelError("error","not supported, you already casting, there's support for one live streaming only"); + return new BadRequestObjectResult(ModelState); + } var uid = User.GetUserId(); // get some setup from user var flow = _dbContext.LiveFlow.SingleOrDefault(f=> (f.OwnerId==uid && f.Id == id)); + if (flow == null) + { + ModelState.AddModelError("error",$"You don't own any flow with the id {id}"); + return new BadRequestObjectResult (ModelState); + } + // Accept the socket var meta = new LiveCastMeta { Socket = await HttpContext.WebSockets.AcceptWebSocketAsync() }; // Dispatch the flow