From 037b9c56f06d47b64192b78e2315e9392a17d11f Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 30 Oct 2024 14:09:08 +0100 Subject: [PATCH] Add support for print logs (#19) --- libpretixsync-repo | 2 +- .../pretixscan/scanproxy/ProxyServer.kt | 1 + .../scanproxy/endpoints/ApiProxy.kt | 20 +++++++++++++++---- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/libpretixsync-repo b/libpretixsync-repo index d045829..3e58a93 160000 --- a/libpretixsync-repo +++ b/libpretixsync-repo @@ -1 +1 @@ -Subproject commit d045829952863e6ddb805f535f542a1590a01860 +Subproject commit 3e58a93250911e83793ba13444ebab2b7107c9f7 diff --git a/server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/ProxyServer.kt b/server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/ProxyServer.kt index e6ee585..bd5b642 100644 --- a/server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/ProxyServer.kt +++ b/server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/ProxyServer.kt @@ -70,6 +70,7 @@ object Server { get("questions/", EmptyResourceEndpoint) get("badgelayouts/", BadgeLayoutEndpoint) get("checkinlists/", CheckInListEndpoint) + post("orderpositions/{positionid}/printlog/", PrintLogEndpoint) get("orders/", EmptyResourceEndpoint) get("badgeitems/", BadgeItemEndpoint) get("settings/", SettingsEndpoint) diff --git a/server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/endpoints/ApiProxy.kt b/server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/endpoints/ApiProxy.kt index ed06b79..12a5e4a 100644 --- a/server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/endpoints/ApiProxy.kt +++ b/server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/endpoints/ApiProxy.kt @@ -1,15 +1,12 @@ package eu.pretix.pretixscan.scanproxy.endpoints import eu.pretix.libpretixsync.db.* -import eu.pretix.pretixscan.scanproxy.ProxyFileStorage -import eu.pretix.pretixscan.scanproxy.Server import eu.pretix.pretixscan.scanproxy.proxyDeps import io.javalin.http.Context import io.javalin.http.Handler import io.javalin.http.NotFoundResponse import java.text.SimpleDateFormat import java.time.LocalDate -import java.util.* object EventEndpoint : Handler { @@ -216,4 +213,19 @@ object EmptyResourceEndpoint : Handler { ) ) } -} \ No newline at end of file +} + +object PrintLogEndpoint : Handler { + override fun handle(ctx: Context) { + val event = proxyDeps.syncData.select(Event::class.java) + .where(Event.SLUG.eq(ctx.pathParam("event"))) + .get().firstOrNull() ?: throw NotFoundResponse("Event not found") + ctx.json(event.json) + + val log = QueuedCall() + log.setBody(ctx.body()) + log.setIdempotency_key(NonceGenerator.nextNonce()) + log.setUrl(proxyDeps.pretixApi.eventResourceUrl(ctx.pathParam("event"), "orderpositions") + ctx.pathParam("positionid") + "/printlog/") + proxyDeps.syncData.insert(log) + } +}