Skip to content

Commit

Permalink
Support new reason "unapproved"
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelm committed Nov 24, 2023
1 parent b5b97bc commit f22c915
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,13 @@ class AsyncCheckProvider(private val config: ConfigStore, private val dataStore:
return res
}

if (order.status != "p" && order.isRequireApproval) {
res.type = TicketCheckProvider.CheckResult.Type.UNAPPROVED
res.isCheckinAllowed = false
storeFailedCheckin(eventSlug, list.getServer_id(), "unapproved", position.secret, type, position = position.getServer_id(), item = position.getItem().getServer_id(), variation = position.getVariation_id(), subevent = position.getSubevent_id(), nonce = nonce)
return res
}

if (type != TicketCheckProvider.CheckInType.EXIT) {
val validFrom = position.validFrom
if (validFrom != null && validFrom.isAfter(now())) {
Expand Down Expand Up @@ -683,13 +690,6 @@ class AsyncCheckProvider(private val config: ConfigStore, private val dataStore:
return TicketCheckProvider.CheckResult(TicketCheckProvider.CheckResult.Type.INVALID, offline = true)
}

if (order.status != "p" && order.isRequireApproval) {
res.type = TicketCheckProvider.CheckResult.Type.UNPAID
res.isCheckinAllowed = false
storeFailedCheckin(eventSlug, list.getServer_id(), "unpaid", position.secret, type, position = position.getServer_id(), item = position.getItem().getServer_id(), variation = position.getVariation_id(), subevent = position.getSubevent_id(), nonce = nonce)
return res
}

if (!order.isValidStatus && !(ignore_unpaid && list.include_pending)) {
res.type = TicketCheckProvider.CheckResult.Type.UNPAID
res.isCheckinAllowed = list.include_pending && !order.isValid_if_pending
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class OnlineCheckProvider(
res.type = TicketCheckProvider.CheckResult.Type.AMBIGUOUS
} else if ("revoked" == reason) {
res.type = TicketCheckProvider.CheckResult.Type.REVOKED
} else if ("unapproved" == reason) {
res.type = TicketCheckProvider.CheckResult.Type.UNAPPROVED
} else if ("unpaid" == reason) {
res.type = TicketCheckProvider.CheckResult.Type.UNPAID
// Decide whether the user is allowed to "try again" with "ignore_unpaid"
Expand All @@ -143,6 +145,8 @@ class OnlineCheckProvider(
res.isCheckinAllowed = includePending && response.has("position") && response.getJSONObject("position").optString("order__status", "n") == "n"
} else if ("product" == reason) {
res.type = TicketCheckProvider.CheckResult.Type.PRODUCT
} else {
res.type = TicketCheckProvider.CheckResult.Type.ERROR
}
if (response.has("reason_explanation") && !response.isNull("reason_explanation")) {
res.reasonExplanation = response.getString("reason_explanation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ interface TicketCheckProvider {
class CheckResult {
enum class Type {
INVALID, VALID, USED, ERROR, UNPAID, BLOCKED, INVALID_TIME, CANCELED, PRODUCT, RULES,
ANSWERS_REQUIRED, AMBIGUOUS, REVOKED
ANSWERS_REQUIRED, AMBIGUOUS, REVOKED, UNAPPROVED
}

var type: Type? = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class AsyncCheckProviderTest : BaseDatabaseTest() {
@Test
fun testRequireApproval() {
var r = p!!.check(mapOf("demo" to 1L), "jugeme335ggtc88tnt9pj853fu4wrf2s")
assertEquals(TicketCheckProvider.CheckResult.Type.UNPAID, r.type)
assertEquals(TicketCheckProvider.CheckResult.Type.UNAPPROVED, r.type)
assertEquals(false, r.isCheckinAllowed)
}

Expand Down

0 comments on commit f22c915

Please sign in to comment.