private static async Task StartOnline(Show show) { if (_options.Offline) { return; } try { var startShow = new StartShow { Presenter = _options.Presenter, Place = _options.Place, Slug = _options.Slug, Time = DateTimeOffset.Now, Title = _options.Title ?? show.Metadata.GetStringOrEmpty("title") }; await _client.StartShow(startShow).ConfigureAwait(false); _logger.LogInformation($"Started: {startShow.Place} {startShow.Presenter} {startShow.Slug} {startShow.Time} {startShow.Title}"); } catch (Exception ex) { _logger.LogError(ex, ex.Message); } }
public async Task <IActionResult> Start(string presenter, [FromBody] StartShow startShow, CancellationToken ct) { if (!ValidateApiKey(presenter)) { return(NotFound()); } startShow.Presenter = presenter; await _messageBus.StartShow(startShow); return(StatusCode(201)); }
public async Task <IActionResult> Start(string handle, [FromBody] StartShow startShow, CancellationToken ct) { var apiKey = Request.Headers["API-Key"]; if (!_apiKeyProvider.CheckBase64(handle, apiKey)) { _logger.LogWarning(EventIds.PresenterInvalidApiKey, "Invalid API key."); return(Forbid()); } startShow.Presenter = handle; var show = await _shows.Start(startShow, ct).ConfigureAwait(false); return(CreatedAtAction("Show", "Live", new { presenter = startShow.Presenter, slug = startShow.Slug }, show)); }
public async Task <Show> Start(StartShow startShow, CancellationToken ct = default(CancellationToken)) { var showRenderer = new ShowRenderer(); var renderedShow = showRenderer.Render(startShow.Markdown); var show = new Show { Place = startShow.Place, Presenter = startShow.Presenter, Slug = startShow.Slug, Time = startShow.Time, Title = renderedShow.Metadata.GetStringOrDefault("title", startShow.Title), Slides = renderedShow.Slides.Select((s, i) => new Slide { Layout = (s.Metadata, renderedShow.Metadata).GetStringOrDefault("layout", "title-and-content"), Html = s.Html, Title = s.Metadata.GetStringOrDefault("title", string.Empty), Slug = startShow.Slug, Presenter = startShow.Presenter, Number = i }).ToList()
public async Task StartShow(StartShow show) { if (_startClient == null) { _logger.LogWarning("No ServiceBus client, message not sent."); return; } try { var data = MessagePackSerializer.Serialize(show); var message = new Message(data); await _startClient.SendAsync(message).ConfigureAwait(false); _logger.LogInformation($"Sent ServiceBus shows/start message."); } catch (System.Exception ex) { _logger.LogError(ex, $"Error sending ServiceBus message: {ex.Message}"); } }