File size: 739 Bytes
7535af1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Telegram.Bot.Types;
using TelegramSaaS.Application.Common.Interfaces.Services;

namespace TelegramSaaS.API.Controllers;

[ApiController]
[Route("api/v1/telegram")]
public class TelegramWebhookController : ControllerBase
{
    private readonly ITelegramUpdateService _updateService;

    public TelegramWebhookController(ITelegramUpdateService updateService)
    {
        _updateService = updateService;
    }

    [HttpPost("webhook")]
    public async Task<IActionResult> ReceiveWebhook([FromBody] Update update)
    {
        if (update == null) return BadRequest();

        await _updateService.HandleUpdateAsync(update);

        return Ok();
    }
}