Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
use_order_locale: Boolean = false,
exchange_medium_type: String? = null,
exchange_medium_identifier: String? = null,
simulate: Boolean = false,
): ApiResponse {
val body = JSONObject()
if (datetime != null) {
Expand Down Expand Up @@ -158,6 +159,7 @@ open class PretixApi(url: String, key: String, orgaSlug: String, version: Int, h
body.put("lists", jlists)
if (exchange_medium_type != null) body.put("exchange_medium_type", exchange_medium_type)
if (exchange_medium_identifier != null) body.put("exchange_medium_identifier", exchange_medium_identifier)
if (simulate) body.put("simulate", true)
var pd = "?expand=answers.question"
if (pdf_data) {
pd += "&pdf_data=true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ data class MultiCheckInput(
val nonce: String?,
val exchange_medium_type: String?,
val exchange_medium_identifier: String?,
val simulate: Boolean = false,
)

data class AnnulInput(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -679,12 +679,20 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa
useOrderLocale: Boolean,
exchange_medium_type: String?,
exchange_medium_identifier: String?,
simulate: Boolean
): TicketCheckProvider.CheckResult {
val nonce = nonce ?: NonceGenerator.nextNonce()
val ticketid_cleaned = cleanInput(ticketid, source_type)

sentry.addBreadcrumb("provider.check", "offline check started")

if (simulate) {
return TicketCheckProvider.CheckResult(
TicketCheckProvider.CheckResult.Type.ERROR,
"Simulate is not supported in offline mode",
)
}

if (exchange_medium_type != null || exchange_medium_identifier != null) {
return TicketCheckProvider.CheckResult(
TicketCheckProvider.CheckResult.Type.ERROR,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class OnlineCheckProvider(
useOrderLocale: Boolean,
exchange_medium_type: String?,
exchange_medium_identifier: String?,
simulate: Boolean,
): TicketCheckProvider.CheckResult {
val ticketid_cleaned = cleanInput(ticketid, source_type)
val nonce_cleaned = nonce ?: NonceGenerator.nextNonce()
Expand All @@ -79,9 +80,11 @@ class OnlineCheckProvider(
use_order_locale = useOrderLocale,
exchange_medium_type = exchange_medium_type,
exchange_medium_identifier = exchange_medium_identifier,
simulate = simulate,
)
} else {
if (eventsAndCheckinLists.size != 1) throw CheckException("Multi-event scan not supported by server.")
if (simulate) throw CheckException("Simulate not supported by this server version.")
api.redeem(
eventsAndCheckinLists.keys.first(),
ticketid_cleaned,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class ProxyCheckProvider(private val config: ConfigStore, httpClientFactory: Htt
useOrderLocale: Boolean,
exchange_medium_type: String?,
exchange_medium_identifier: String?,
simulate: Boolean
): TicketCheckProvider.CheckResult {
val answersInput = answers?.map {
val questionModel = it.question as Question // TODO: Can we avoid the cast?
Expand All @@ -137,6 +138,7 @@ class ProxyCheckProvider(private val config: ConfigStore, httpClientFactory: Htt
nonce = nonce,
exchange_medium_type = exchange_medium_type,
exchange_medium_identifier = exchange_medium_identifier,
simulate = simulate,
)

return try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ interface TicketCheckProvider {
useOrderLocale: Boolean = false,
exchange_medium_type: String? = null,
exchange_medium_identifier: String? = null,
simulate: Boolean = false
): CheckResult

fun check(eventsAndCheckinLists: Map<String, Long>, ticketid: String, source_type: String = "barcode"): CheckResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class FakePretixApi(var orgaSlug: String = "demo") : PretixApi("http://1.1.1.1/"
use_order_locale: Boolean,
exchange_medium_type: String?,
exchange_medium_identifier: String?,
simulate: Boolean,
): ApiResponse {
redeemRequestSecret = secret
redeemRequestDatetime = datetime
Expand Down
Loading