private async Task HandleUpdateAsync(Update update, CancellationToken ct) { using var scope = this.scopeFactory.CreateScope(); var context = (MarketplaceContext)scope.ServiceProvider.GetService(typeof(MarketplaceContext)); var(userId, command, messageId) = UpdateHelpers.GetUserAndCommand(update); var user = await context.Users.FirstOrDefaultAsync(u => u.TelegramId == userId); if (user != null && user.IsBanned) { return; } var userContext = this.userContextService.GetUserContext(user, userId); PersonifiedUpdate personifiedUpdate = new PersonifiedUpdate() { Update = update, UserContext = userContext, Command = command, MessageId = messageId, }; var updateHandler = (IBotUpdateService)scope.ServiceProvider.GetService(typeof(IBotUpdateService)); await updateHandler.ProceedUpdate(personifiedUpdate); }
public async Task <IActionResult> Post([FromBody] Update update) { var(userId, command, messageId) = UpdateHelpers.GetUserAndCommand(update); var user = await this.context.Users.FirstOrDefaultAsync(u => u.TelegramId == userId); if (user != null && user.IsBanned) { return(this.Ok()); } var userContext = this.userContextService.GetUserContext(user, userId); PersonifiedUpdate personifiedUpdate = new PersonifiedUpdate() { Update = update, UserContext = userContext, Command = command, MessageId = messageId, }; await this.botUpdate.ProceedUpdate(personifiedUpdate); return(this.Ok()); }