From efb20e470b73601421b8e6856d3f1dbc0b1c2e15 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Fri, 24 Nov 2023 13:51:17 +0100 Subject: [PATCH] Fix compatibility with older pretix versions --- .../check/OnlineCheckProvider.kt | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) 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 983a1c14..e6e2fba2 100644 --- a/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/OnlineCheckProvider.kt +++ b/libpretixsync/src/main/java/eu/pretix/libpretixsync/check/OnlineCheckProvider.kt @@ -210,14 +210,21 @@ class OnlineCheckProvider( for (i in 0 until (posjson.getJSONArray("answers").length())) { val a = posjson.getJSONArray("answers").getJSONObject(i) val value = a.getString("answer") - val q = a.getJSONObject("question") - val question = Question() - question.setServer_id(q.getLong("id")) - question.isRequired = q.getBoolean("required") - question.setPosition(q.getLong("position")) - question.setJson_data(q.toString()) - if (question.isShowDuringCheckin) { - shownAnswers.add(TicketCheckProvider.QuestionAnswer(question, value)) + val q = a.get("question") + if (q is JSONObject) { // pretix version supports the expand parameter + val question = Question() + question.setServer_id(q.getLong("id")) + question.isRequired = q.getBoolean("required") + question.setPosition(q.getLong("position")) + question.setJson_data(q.toString()) + if (question.isShowDuringCheckin) { + shownAnswers.add( + TicketCheckProvider.QuestionAnswer( + question, + value + ) + ) + } } } res.shownAnswers = shownAnswers