Change logging to just log a message, instead of the exception. Moved logic to Syncer involvement. When posting the data, if a 500 is returned, then it is up to the Syncer to re-submit it.
29 lines
No EOL
913 B
C#
29 lines
No EOL
913 B
C#
using FreeTubeSync.Database;
|
|
|
|
namespace FreeTubeSync.EndPoints;
|
|
|
|
public static class PingEndpoint
|
|
{
|
|
public static void MapPingEndpoints(this WebApplication app)
|
|
{
|
|
var group = app.MapGroup("ping");
|
|
group.MapGet("/", async (DataContext dbContext, CancellationToken token) =>
|
|
{
|
|
await dbContext.CleanupChangeLogAsync(token);
|
|
var dict = new { AppVersion = "0.1.5" };
|
|
return Results.Ok(dict);
|
|
});
|
|
|
|
group.MapGet("/lastUpdated", async (DataContext dbContext, CancellationToken token) =>
|
|
{
|
|
var log = await dbContext.GetLatestChangeAsync(token);
|
|
|
|
if (log == null)
|
|
return Results.NotFound();
|
|
|
|
var dict = new { LastUpdated = log.ChangeTime };
|
|
await dbContext.CleanupChangeLogAsync(token);
|
|
return Results.Ok(dict);
|
|
});
|
|
}
|
|
} |