diff --git a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/AsyncCheckProvider.kt b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/AsyncCheckProvider.kt index 6fbc0c51..e3358d06 100644 --- a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/AsyncCheckProvider.kt +++ b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/AsyncCheckProvider.kt @@ -51,7 +51,19 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa this.sentry = sentry } - private fun storeFailedCheckin(eventSlug: String, listId: Long, error_reason: String, raw_barcode: String, type: TicketCheckProvider.CheckInType, position: Long? = null, item: Long? = null, variation: Long? = null, subevent: Long? = null, nonce: String?) { + private fun storeFailedCheckin( + eventSlug: String, + listId: Long, + error_reason: String, + raw_barcode: String, + raw_source_type: String, + type: TicketCheckProvider.CheckInType, + position: Long? = null, + item: Long? = null, + variation: Long? = null, + subevent: Long? = null, + nonce: String? + ) { /* : "entry" TicketCheckProvider.CheckInType.EXIT -> "exit" @@ -287,6 +300,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa private fun checkOfflineWithoutData( eventsAndCheckinLists: Map, ticketid: String, + source_type: String, type: TicketCheckProvider.CheckInType, answers: List?, nonce: String?, @@ -305,7 +319,15 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa } if (decoded == null || event == null) { val firstentry = eventsAndCheckinLists.entries.first() - storeFailedCheckin(firstentry.key, firstentry.value, "invalid", ticketid, type, nonce = nonce) + storeFailedCheckin( + firstentry.key, + firstentry.value, + "invalid", + ticketid, + source_type, + type, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.INVALID, offline = true) } val listId = eventsAndCheckinLists[event.slug] ?: return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.ERROR, "Check-in list not set for event", offline = true) @@ -318,23 +340,61 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa val is_revoked = db.revokedTicketSecretQueries.countForSecret(ticketid).executeAsOne() if (is_revoked > 0) { - storeFailedCheckin(eventSlug, listId, "revoked", ticketid, type, nonce = nonce) + storeFailedCheckin( + eventSlug, + listId, + "revoked", + ticketid, + source_type, + type, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.REVOKED, offline = true) } val is_blocked = db.blockedTicketSecretQueries.countBlockedForSecret(ticketid).executeAsOne() if (is_blocked > 0) { - storeFailedCheckin(eventSlug, listId, "blocked", ticketid, type, nonce = nonce) + storeFailedCheckin( + eventSlug, + listId, + "blocked", + ticketid, + source_type, + type, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.BLOCKED, offline = true) } if (type != TicketCheckProvider.CheckInType.EXIT) { if (decoded.validFrom?.isAfter(now()) == true) { - storeFailedCheckin(eventSlug, listId, "invalid_time", ticketid, type, item = decoded.item, variation = decoded.variation, subevent = decoded.subevent, nonce = nonce) + storeFailedCheckin( + eventSlug, + listId, + "invalid_time", + ticketid, + source_type, + type, + item = decoded.item, + variation = decoded.variation, + subevent = decoded.subevent, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.INVALID_TIME, offline = true) } if (decoded.validUntil?.isBefore(now()) == true) { - storeFailedCheckin(eventSlug, listId, "invalid_time", ticketid, type, item = decoded.item, variation = decoded.variation, subevent = decoded.subevent, nonce = nonce) + storeFailedCheckin( + eventSlug, + listId, + "invalid_time", + ticketid, + source_type, + type, + item = decoded.item, + variation = decoded.variation, + subevent = decoded.subevent, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.INVALID_TIME, offline = true) } } @@ -345,13 +405,32 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa item_server_id = decoded.item, ).executeAsOne() if (is_in_list == 0L) { - storeFailedCheckin(eventSlug, listId, "product", ticketid, type, item = decoded.item, variation = decoded.variation, subevent = decoded.subevent, nonce = nonce) + storeFailedCheckin( + eventSlug, + listId, + "product", + ticketid, + source_type, + type, + item = decoded.item, + variation = decoded.variation, + subevent = decoded.subevent, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.PRODUCT, offline = true) } } if (list.subEventId != null && list.subEventId > 0 && list.subEventId != decoded.subevent) { - storeFailedCheckin(eventSlug, listId, "invalid", ticketid, type, nonce = nonce) + storeFailedCheckin( + eventSlug, + listId, + "invalid", + ticketid, + source_type, + type, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.INVALID, offline = true) } @@ -360,7 +439,16 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa event_slug = eventSlug, ).executeAsOneOrNull()?.toModel() if (item == null) { - storeFailedCheckin(eventSlug, listId, "error", ticketid, type, subevent = decoded.subevent, nonce = nonce) + storeFailedCheckin( + eventSlug, + listId, + "error", + ticketid, + source_type, + type, + subevent = decoded.subevent, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.ERROR, "Item not found", offline = true) } @@ -454,6 +542,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa listId, "rules", ticketid, + source_type, type, item = decoded.item, variation = decoded.variation, @@ -471,6 +560,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa listId, "rules", ticketid, + source_type, type, item = decoded.item, variation = decoded.variation, @@ -520,7 +610,18 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa res.isCheckinAllowed = false res.firstScanned = queuedCheckIns.first().fullDateTime res.type = TicketCheckProvider.CheckResult.Type.USED - storeFailedCheckin(eventSlug, listId, "already_redeemed", ticketid, type, item = decoded.item, variation = decoded.variation, subevent = decoded.subevent, nonce = nonce) + storeFailedCheckin( + eventSlug, + listId, + "already_redeemed", + ticketid, + source_type, + type, + item = decoded.item, + variation = decoded.variation, + subevent = decoded.subevent, + nonce = nonce + ) } else { res.isCheckinAllowed = true res.type = TicketCheckProvider.CheckResult.Type.VALID @@ -542,8 +643,8 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa // todo document missing stuff: rules, badge printing, questions } - override fun check(eventsAndCheckinLists: Map, ticketid: String): TicketCheckProvider.CheckResult { - return check(eventsAndCheckinLists, ticketid, "barcode", ArrayList(), false, true, TicketCheckProvider.CheckInType.ENTRY) + override fun check(eventsAndCheckinLists: Map, ticketid: String, source_type: String): TicketCheckProvider.CheckResult { + return check(eventsAndCheckinLists, ticketid, source_type, ArrayList(), false, true, TicketCheckProvider.CheckInType.ENTRY) } override fun check( @@ -578,7 +679,18 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa ).executeAsList().map { it.toModel() } if (tickets.size == 1) { - return checkOfflineWithData(eventsAndCheckinLists, ticketid_cleaned, tickets, answers, ignore_unpaid, type, nonce = nonce, allowQuestions = allowQuestions, mediumUsed = false) + return checkOfflineWithData( + eventsAndCheckinLists, + ticketid_cleaned, + source_type, + tickets, + answers, + ignore_unpaid, + type, + nonce = nonce, + allowQuestions = allowQuestions, + mediumUsed = false + ) } else if (tickets.size > 1) { val eventSlug = db.orderQueries.selectById(tickets[0].orderId).executeAsOne().event_slug!! val itemServerId = db.itemQueries.selectById(tickets[0].itemId).executeAsOne().server_id @@ -591,6 +703,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa ), "ambiguous", ticketid_cleaned, + source_type, type, position = tickets[0].serverId, item = itemServerId, @@ -609,8 +722,15 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa if (medium != null) { val firstentry = eventsAndCheckinLists.entries.first() if (!medium.active) { - // FIXME: note that this was an medium source - storeFailedCheckin(firstentry.key, firstentry.value, "invalid", ticketid, type, nonce = nonce) + storeFailedCheckin( + firstentry.key, + firstentry.value, + "invalid", + ticketid, + source_type, + type, + nonce = nonce + ) return TicketCheckProvider.CheckResult( TicketCheckProvider.CheckResult.Type.INVALID, "Medium not active", @@ -619,8 +739,15 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa } if (medium.expires?.isBefore(javaTimeNow()) == true) { - // FIXME: note that this was an medium source - storeFailedCheckin(firstentry.key, firstentry.value, "invalid", ticketid, type, nonce = nonce) + storeFailedCheckin( + firstentry.key, + firstentry.value, + "invalid", + ticketid, + source_type, + type, + nonce = nonce + ) return TicketCheckProvider.CheckResult( TicketCheckProvider.CheckResult.Type.INVALID, "Medium expired", @@ -638,6 +765,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa return checkOfflineWithData( eventsAndCheckinLists, ticketid_cleaned, + source_type, tickets, answers, ignore_unpaid, @@ -651,6 +779,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa return checkOfflineWithoutData( eventsAndCheckinLists, ticketid_cleaned, + source_type, type, answers ?: emptyList(), nonce, @@ -804,6 +933,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa private fun checkOfflineWithData( eventsAndCheckinLists: Map, secret: String, + source_type: String, tickets: List, answers: List?, ignore_unpaid: Boolean, @@ -823,11 +953,47 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa if (firstError.list != null) { when (firstError.error) { TicketCheckProvider.CheckResult.Type.PRODUCT -> - storeFailedCheckin(firstError.eventSlug, firstError.list.serverId, "product", secret, type, position = firstError.position.serverId, item = item.serverId, variation = firstError.position.variationServerId, subevent = firstError.position.subEventServerId, nonce = nonce) + storeFailedCheckin( + firstError.eventSlug, + firstError.list.serverId, + "product", + secret, + source_type, + type, + position = firstError.position.serverId, + item = item.serverId, + variation = firstError.position.variationServerId, + subevent = firstError.position.subEventServerId, + nonce = nonce + ) TicketCheckProvider.CheckResult.Type.AMBIGUOUS -> - storeFailedCheckin(firstError.eventSlug, firstError.list.serverId, "ambiguous", secret, type, position = firstError.position.serverId, item = item.serverId, variation = firstError.position.variationServerId, subevent = firstError.position.subEventServerId, nonce = nonce) + storeFailedCheckin( + firstError.eventSlug, + firstError.list.serverId, + "ambiguous", + secret, + source_type, + type, + position = firstError.position.serverId, + item = item.serverId, + variation = firstError.position.variationServerId, + subevent = firstError.position.subEventServerId, + nonce = nonce + ) TicketCheckProvider.CheckResult.Type.INVALID_TIME -> - storeFailedCheckin(firstError.eventSlug, firstError.list.serverId, "invalid_time", secret, type, position = firstError.position.serverId, item = item.serverId, variation = firstError.position.variationServerId, subevent = firstError.position.subEventServerId, nonce = nonce) + storeFailedCheckin( + firstError.eventSlug, + firstError.list.serverId, + "invalid_time", + secret, + source_type, + type, + position = firstError.position.serverId, + item = item.serverId, + variation = firstError.position.variationServerId, + subevent = firstError.position.subEventServerId, + nonce = nonce + ) else -> {} } } @@ -882,7 +1048,19 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa JSONObject(db.orderPositionQueries.selectById(position.id).executeAsOne().json_data) } catch (e: JSONException) { sentry.captureException(e) - storeFailedCheckin(eventSlug, list.serverId, "error", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "error", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.ERROR, offline = true) } @@ -929,21 +1107,57 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa if (order.status != OrderModel.Status.PAID && order.status != OrderModel.Status.PENDING) { res.type = TicketCheckProvider.CheckResult.Type.CANCELED res.isCheckinAllowed = false - storeFailedCheckin(eventSlug, list.serverId, "canceled", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "canceled", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return res } if (position.blocked) { res.type = TicketCheckProvider.CheckResult.Type.BLOCKED res.isCheckinAllowed = false - storeFailedCheckin(eventSlug, list.serverId, "blocked", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "blocked", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return res } if (order.status != OrderModel.Status.PAID && order.requiresApproval) { res.type = TicketCheckProvider.CheckResult.Type.UNAPPROVED res.isCheckinAllowed = false - storeFailedCheckin(eventSlug, list.serverId, "unapproved", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "unapproved", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return res } @@ -952,14 +1166,38 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa if (validFrom != null && validFrom.isAfter(javaTimeNow())) { res.type = TicketCheckProvider.CheckResult.Type.INVALID_TIME res.isCheckinAllowed = false - storeFailedCheckin(eventSlug, list.serverId, "invalid_time", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "invalid_time", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return res } val validUntil = position.validUntil if (validUntil != null && validUntil.isBefore(javaTimeNow())) { res.type = TicketCheckProvider.CheckResult.Type.INVALID_TIME res.isCheckinAllowed = false - storeFailedCheckin(eventSlug, list.serverId, "invalid_time", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "invalid_time", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return res } } @@ -970,7 +1208,19 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa item_server_id = item.serverId, ).executeAsOne() if (is_in_list == 0L) { - storeFailedCheckin(eventSlug, list.serverId, "product", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "product", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) res.type = TicketCheckProvider.CheckResult.Type.PRODUCT res.isCheckinAllowed = false return res @@ -978,14 +1228,38 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa } if (list.subEventId != null && list.subEventId > 0 && list.subEventId != position.subEventServerId) { - storeFailedCheckin(eventSlug, list.subEventId, "invalid", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.subEventId, + "invalid", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.INVALID, offline = true) } if (!order.hasValidStatus && !(ignore_unpaid && list.includePending)) { res.type = TicketCheckProvider.CheckResult.Type.UNPAID res.isCheckinAllowed = list.includePending && !order.validIfPending - storeFailedCheckin(eventSlug, list.serverId, "unpaid", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "unpaid", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return res } @@ -1001,12 +1275,36 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa res.type = TicketCheckProvider.CheckResult.Type.EXCHANGE_REQUIRED_OFFLINE res.isCheckinAllowed = false res.reasonExplanation = "This ticket needs to be exchanged, but this isn't possible while offline" - storeFailedCheckin(eventSlug, list.serverId, "exchange", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "exchange", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return res } else if (reusableMediaUsageEnforced) { res.type = TicketCheckProvider.CheckResult.Type.ALREADY_EXCHANGED res.isCheckinAllowed = false - storeFailedCheckin(eventSlug, list.serverId, "already_exchanged", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "already_exchanged", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) return res } } @@ -1074,6 +1372,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa list.serverId, "rules", position.secret!!, + source_type, type, position = position.serverId, item = positionItem.serverId, @@ -1092,6 +1391,7 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa list.serverId, "rules", position.secret!!, + source_type, type, position = position.serverId, item = positionItem.serverId, @@ -1146,7 +1446,19 @@ class AsyncCheckProvider(private val config: ConfigStore, private val db: SyncDa res.isCheckinAllowed = false res.firstScanned = checkIns.first().fullDateTime.toDate() res.type = TicketCheckProvider.CheckResult.Type.USED - storeFailedCheckin(eventSlug, list.serverId, "already_redeemed", position.secret!!, type, position = position.serverId, item = positionItem.serverId, variation = position.variationServerId, subevent = position.subEventServerId, nonce = nonce) + storeFailedCheckin( + eventSlug, + list.serverId, + "already_redeemed", + position.secret!!, + source_type, + type, + position = position.serverId, + item = positionItem.serverId, + variation = position.variationServerId, + subevent = position.subEventServerId, + nonce = nonce + ) } else { res.isCheckinAllowed = true res.type = TicketCheckProvider.CheckResult.Type.VALID diff --git a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/OnlineCheckProvider.kt b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/OnlineCheckProvider.kt index 8713e630..92260da7 100644 --- a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/OnlineCheckProvider.kt +++ b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/OnlineCheckProvider.kt @@ -348,8 +348,8 @@ class OnlineCheckProvider( } } - override fun check(eventsAndCheckinLists: Map, ticketid: String): TicketCheckProvider.CheckResult { - return check(eventsAndCheckinLists, ticketid, "barcode", ArrayList(), false, true, TicketCheckProvider.CheckInType.ENTRY) + override fun check(eventsAndCheckinLists: Map, ticketid: String, source_type: String): TicketCheckProvider.CheckResult { + return check(eventsAndCheckinLists, ticketid, source_type, ArrayList(), false, true, TicketCheckProvider.CheckInType.ENTRY) } @Throws(CheckException::class) diff --git a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/ProxyCheckProvider.kt b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/ProxyCheckProvider.kt index 550d59ea..156af955 100644 --- a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/ProxyCheckProvider.kt +++ b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/ProxyCheckProvider.kt @@ -162,8 +162,8 @@ class ProxyCheckProvider(private val config: ConfigStore, httpClientFactory: Htt } } - override fun check(eventsAndCheckinLists: Map, ticketid: String): TicketCheckProvider.CheckResult { - return check(eventsAndCheckinLists, ticketid, "barcode", ArrayList(), false, true, TicketCheckProvider.CheckInType.ENTRY) + override fun check(eventsAndCheckinLists: Map, ticketid: String, source_type: String): TicketCheckProvider.CheckResult { + return check(eventsAndCheckinLists, ticketid, source_type, ArrayList(), false, true, TicketCheckProvider.CheckInType.ENTRY) } @Throws(CheckException::class) diff --git a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/TicketCheckProvider.kt b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/TicketCheckProvider.kt index 971d30f2..545827fa 100644 --- a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/TicketCheckProvider.kt +++ b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/TicketCheckProvider.kt @@ -178,7 +178,7 @@ interface TicketCheckProvider { exchange_medium_identifier: String? = null, ): CheckResult - fun check(eventsAndCheckinLists: Map, ticketid: String): CheckResult + fun check(eventsAndCheckinLists: Map, ticketid: String, source_type: String = "barcode"): CheckResult @Throws(CheckException::class) fun search(eventsAndCheckinLists: Map, query: String, page: Int): List diff --git a/libpretixsync/src/test/java/eu/pretix/libpretixsync/check/AsyncCheckProviderReusableMediumTest.kt b/libpretixsync/src/test/java/eu/pretix/libpretixsync/check/AsyncCheckProviderReusableMediumTest.kt index 003d8e5c..673bb0aa 100644 --- a/libpretixsync/src/test/java/eu/pretix/libpretixsync/check/AsyncCheckProviderReusableMediumTest.kt +++ b/libpretixsync/src/test/java/eu/pretix/libpretixsync/check/AsyncCheckProviderReusableMediumTest.kt @@ -1,6 +1,7 @@ package eu.pretix.libpretixsync.check import eu.pretix.libpretixsync.db.BaseDatabaseTest +import eu.pretix.libpretixsync.sqldelight.QueuedCall import eu.pretix.libpretixsync.sync.CheckInListSyncAdapter import eu.pretix.libpretixsync.sync.EventSyncAdapter import eu.pretix.libpretixsync.sync.ItemSyncAdapter @@ -11,6 +12,7 @@ import eu.pretix.pretixscan.scanproxy.tests.test.FakeFileStorage import eu.pretix.pretixscan.scanproxy.tests.test.FakePretixApi import eu.pretix.pretixscan.scanproxy.tests.test.jsonResource import org.joda.time.format.ISODateTimeFormat +import org.json.JSONObject import org.junit.Before import org.junit.Test @@ -137,4 +139,19 @@ class AsyncCheckProviderReusableMediumTest : BaseDatabaseTest() { assertEquals(TicketCheckProvider.CheckResult.Type.INVALID_TIME, r.type) assertEquals("W0JKM-7", r.orderCodeAndPositionId()) } + + + @Test + fun testMediumExpiredFailedCheckinSourceTypeStored() { + val sourceType = "nfc_uid" + assertEquals(0, db.queuedCallQueries.count().executeAsOne()) + p!!.setNow(ISODateTimeFormat.dateTime().parseDateTime("2026-01-01T00:00:01.000Z")) + val r = p!!.check(mapOf("event1" to 35L), "6666", sourceType) + assertEquals(TicketCheckProvider.CheckResult.Type.INVALID, r.type) + + assertEquals(1, db.queuedCallQueries.count().executeAsOne()) + val queuedCall : QueuedCall = db.queuedCallQueries.selectAll().executeAsList().first() + val data = JSONObject(queuedCall.body) + assertEquals(sourceType, data.getString("raw_source_type")) + } }