Skip to content

Commit 037b9c5

Browse files
authored
Add support for print logs (#19)
1 parent 6cc93c8 commit 037b9c5

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/ProxyServer.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ object Server {
7070
get("questions/", EmptyResourceEndpoint)
7171
get("badgelayouts/", BadgeLayoutEndpoint)
7272
get("checkinlists/", CheckInListEndpoint)
73+
post("orderpositions/{positionid}/printlog/", PrintLogEndpoint)
7374
get("orders/", EmptyResourceEndpoint)
7475
get("badgeitems/", BadgeItemEndpoint)
7576
get("settings/", SettingsEndpoint)

server/src/main/kotlin/eu/pretix/pretixscan/scanproxy/endpoints/ApiProxy.kt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package eu.pretix.pretixscan.scanproxy.endpoints
22

33
import eu.pretix.libpretixsync.db.*
4-
import eu.pretix.pretixscan.scanproxy.ProxyFileStorage
5-
import eu.pretix.pretixscan.scanproxy.Server
64
import eu.pretix.pretixscan.scanproxy.proxyDeps
75
import io.javalin.http.Context
86
import io.javalin.http.Handler
97
import io.javalin.http.NotFoundResponse
108
import java.text.SimpleDateFormat
119
import java.time.LocalDate
12-
import java.util.*
1310

1411

1512
object EventEndpoint : Handler {
@@ -216,4 +213,19 @@ object EmptyResourceEndpoint : Handler {
216213
)
217214
)
218215
}
219-
}
216+
}
217+
218+
object PrintLogEndpoint : Handler {
219+
override fun handle(ctx: Context) {
220+
val event = proxyDeps.syncData.select(Event::class.java)
221+
.where(Event.SLUG.eq(ctx.pathParam("event")))
222+
.get().firstOrNull() ?: throw NotFoundResponse("Event not found")
223+
ctx.json(event.json)
224+
225+
val log = QueuedCall()
226+
log.setBody(ctx.body())
227+
log.setIdempotency_key(NonceGenerator.nextNonce())
228+
log.setUrl(proxyDeps.pretixApi.eventResourceUrl(ctx.pathParam("event"), "orderpositions") + ctx.pathParam("positionid") + "/printlog/")
229+
proxyDeps.syncData.insert(log)
230+
}
231+
}

0 commit comments

Comments
 (0)