History Polling: Message-ID-basiert, neuer /api/history/poll Endpoint
This commit is contained in:
1 parent
19f926da05
commit
fb2c3a0720
5 files changed
+90
-25
No files matched your search
@@ -14,6 +14,7 @@ public static class HistoryEndpoint
|
||||
public static void MapHistoryEndpoint(this IEndpointRouteBuilder app)
|
||||
{
|
||||
app.MapGet("/api/history", HandleHistory);
|
||||
app.MapGet("/api/history/poll", HandlePoll);
|
||||
}
|
||||
|
||||
private static async Task HandleHistory(HttpContext ctx, DatabaseService db)
|
||||
@@ -37,4 +38,13 @@ public static class HistoryEndpoint
|
||||
|
||||
await ctx.Response.WriteAsJsonAsync(result);
|
||||
}
|
||||
|
||||
private static async Task HandlePoll(HttpContext ctx, DatabaseService db)
|
||||
{
|
||||
var afterStr = ctx.Request.Query["afterId"].FirstOrDefault();
|
||||
var afterId = long.TryParse(afterStr, out var a) ? a : 0;
|
||||
|
||||
var messages = await db.GetMessagesAfterId(afterId);
|
||||
await ctx.Response.WriteAsJsonAsync(messages);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user