diff --git a/src/Nullinside.Api.TwitchBot/Controllers/BotController.cs b/src/Nullinside.Api.TwitchBot/Controllers/BotController.cs index 927d1e1..66ed740 100644 --- a/src/Nullinside.Api.TwitchBot/Controllers/BotController.cs +++ b/src/Nullinside.Api.TwitchBot/Controllers/BotController.cs @@ -2,6 +2,7 @@ using log4net; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; @@ -132,6 +133,24 @@ public async Task GetConfig(CancellationToken token) { BanKnownBots = config.BanKnownBots }); } + + /// + /// Gets the timestamp of the last time a chat message was received. + /// + /// The cancellation token. + /// The timestamp of the last message received. + [AllowAnonymous] + [HttpGet] + [Route("chat/timestamp")] + public async Task GetLastChatTimestamp(CancellationToken token) { + var message = + await _dbContext.TwitchUserChatLogs.OrderByDescending(c => c.Timestamp).FirstOrDefaultAsync(token); + if (null == message) { + return StatusCode(500); + } + + return Ok(message.Timestamp); + } /// /// Updates the configuration. diff --git a/src/nullinside-api b/src/nullinside-api index 7f2f783..7ff66dc 160000 --- a/src/nullinside-api +++ b/src/nullinside-api @@ -1 +1 @@ -Subproject commit 7f2f783e4e24ca00aff35ed7e8c1d76bd797012d +Subproject commit 7ff66dc050258595fb7718ba03880c5094adff58