From d578f6a41387bb1727b774c269db36bcd6070394 Mon Sep 17 00:00:00 2001 From: Sergey Gut Date: Sun, 28 Jan 2024 20:25:12 +0300 Subject: [PATCH] Small cleanup --- Core/Controllers/Telegram.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Core/Controllers/Telegram.cs b/Core/Controllers/Telegram.cs index 21ac958..acdc2c7 100644 --- a/Core/Controllers/Telegram.cs +++ b/Core/Controllers/Telegram.cs @@ -10,7 +10,6 @@ using Telegram.Bot.Types; namespace Kruzya.TelegramBot.Core.Controllers { - [Route("/Telegram")] public class Telegram : Controller { private const string SecretTokenHeader = "X-Telegram-Bot-Api-Secret-Token"; @@ -33,9 +32,8 @@ namespace Kruzya.TelegramBot.Core.Controllers } } - [Route("/WebHook")] [HttpPost] - public IActionResult Index() + public IActionResult Index([FromBody] Update? update) { if (_secretToken != null && !Request.Headers.ContainsKey(SecretTokenHeader)) { @@ -50,15 +48,14 @@ namespace Kruzya.TelegramBot.Core.Controllers return BadRequest(); } - LaunchHandle(); + LaunchHandle(update); return Ok(); } - private void LaunchHandle() + private void LaunchHandle(Update? update) { try { - var update = JsonConvert.DeserializeObject(Request.Body.ToString()); if (update == null) { throw new System.Exception("Invalid request body");