public async Task <GetNotificationChannelListResponse> GetListAsync(GetNotificationChannelListRequest request) { var items = await _notificationChannelsRepository.GetAsync(); return(new GetNotificationChannelListResponse { Items = items }); }
public async Task SendAsync(string channelId, string text) { NotificationChannel channel = null; try { channel = await _notificationChannelsRepository.GetAsync(channelId); if (channel == null) { throw new Exception($"Failed to to send message to telegram. Channel with id {channelId} not found"); } await RetryPolicy.ExecuteAsync(async() => await _telegramBotClient.SendTextMessageAsync(channel.ChatId, text, ParseMode.Html)); } catch (Exception ex) { _logger.LogError(ex, "Failed to send message to telegram by channel {@Channel}. {@ExMessage}", channel?.Name, ex.Message); } }