mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2026-10-22 23:12:12 +03:00
Add option to install a userscript instead of manually copying the tracking script
This commit is contained in:
11 files changed
+411
-58
No files matched your search
@@ -0,0 +1,18 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using DHT.Server.Service.Middlewares;
|
||||
using DHT.Utils.Resources;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace DHT.Server.Endpoints;
|
||||
|
||||
[ServerAuthorizationMiddleware.NoAuthorization]
|
||||
sealed class GetUserscriptEndpoint(ResourceLoader resources) : BaseEndpoint {
|
||||
protected override async Task Respond(HttpRequest request, HttpResponse response, CancellationToken cancellationToken) {
|
||||
const string FileName = "dht.user.js";
|
||||
const string ResourcePath = "Tracker/loader/" + FileName;
|
||||
|
||||
byte[]? resourceBytes = await resources.ReadBytesAsyncIfExists(ResourcePath);
|
||||
await WriteFileIfFound(response, FileName, resourceBytes, cancellationToken);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user