| | | 1 | | using Microsoft.Extensions.Hosting; |
| | | 2 | | using TeleFlow.Telegram.Internal; |
| | | 3 | | |
| | | 4 | | namespace TeleFlow.Telegram.Webhooks.Internal; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Resolves the current bot identity before the ASP.NET Core host starts accepting Telegram webhook updates, |
| | | 8 | | /// allowing command routing to reject mentions addressed to another bot without network access per update. |
| | | 9 | | /// </summary> |
| | | 10 | | internal sealed class TelegramBotIdentityStartupService( |
| | | 11 | | ITelegramClient bot, |
| | | 12 | | TelegramBotIdentity botIdentity) : IHostedLifecycleService |
| | | 13 | | { |
| | | 14 | | public Task StartingAsync(CancellationToken cancellationToken) |
| | | 15 | | { |
| | 0 | 16 | | return botIdentity.EnsureResolvedAsync(bot, cancellationToken); |
| | | 17 | | } |
| | | 18 | | |
| | | 19 | | public Task StartAsync(CancellationToken cancellationToken) |
| | | 20 | | { |
| | 0 | 21 | | return Task.CompletedTask; |
| | | 22 | | } |
| | | 23 | | |
| | | 24 | | public Task StartedAsync(CancellationToken cancellationToken) |
| | | 25 | | { |
| | 0 | 26 | | return Task.CompletedTask; |
| | | 27 | | } |
| | | 28 | | |
| | | 29 | | public Task StoppingAsync(CancellationToken cancellationToken) |
| | | 30 | | { |
| | 0 | 31 | | return Task.CompletedTask; |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | public Task StopAsync(CancellationToken cancellationToken) |
| | | 35 | | { |
| | 0 | 36 | | return Task.CompletedTask; |
| | | 37 | | } |
| | | 38 | | |
| | | 39 | | public Task StoppedAsync(CancellationToken cancellationToken) |
| | | 40 | | { |
| | 0 | 41 | | return Task.CompletedTask; |
| | | 42 | | } |
| | | 43 | | } |