1
0
mirror of https://github.com/chylex/Discord-History-Tracker.git synced 2024-11-21 20:42:45 +01:00
Discord-History-Tracker/app/Server/Endpoints/GetViewerMetadataEndpoint.cs

20 lines
718 B
C#

using System.Net.Mime;
using System.Threading;
using System.Threading.Tasks;
using DHT.Server.Database;
using DHT.Server.Database.Export;
using DHT.Server.Service.Viewer;
using Microsoft.AspNetCore.Http;
namespace DHT.Server.Endpoints;
sealed class GetViewerMetadataEndpoint(IDatabaseFile db, ViewerSessions viewerSessions) : BaseEndpoint(db) {
protected override Task Respond(HttpRequest request, HttpResponse response, CancellationToken cancellationToken) {
var sessionId = GetSessionId(request);
var session = viewerSessions.Get(sessionId);
response.ContentType = MediaTypeNames.Application.Json;
return ViewerJsonExport.GetMetadata(response.Body, Db, session.MessageFilter, cancellationToken);
}
}