Skip to content

Commit 8b1df57

Browse files
pc-coholicrobbi5
authored andcommitted
Split reusable components of pretix' NFC usage across libpretixnfc, libpretixsync and libpretixui
1 parent 04aaf60 commit 8b1df57

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package eu.pretix.libpretixsync.utils
2+
3+
import eu.pretix.libpretixsync.db.ReusableMediaType
4+
5+
fun getActiveMediaTypes(
6+
settingsManager: SettingsManager,
7+
eventSlug: String?
8+
): List<ReusableMediaType> {
9+
if (eventSlug.isNullOrBlank()) {
10+
return emptyList()
11+
}
12+
13+
val settings = settingsManager.getBySlug(eventSlug)
14+
if (settings == null) {
15+
return emptyList()
16+
}
17+
val l = mutableListOf<ReusableMediaType>()
18+
19+
if (settings.json.optBoolean("reusable_media_type_barcode")) {
20+
l.add(ReusableMediaType.BARCODE)
21+
}
22+
if (settings.json.optBoolean("reusable_media_type_nfc_uid")) {
23+
l.add(ReusableMediaType.NFC_UID)
24+
} else {
25+
if (settings.json.optBoolean("reusable_media_type_nfc_mf0aes")) {
26+
l.add(ReusableMediaType.NFC_MF0AES)
27+
}
28+
}
29+
return l
30+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package eu.pretix.libpretixsync.utils
2+
3+
import eu.pretix.libpretixsync.models.Settings
4+
5+
interface SettingsManager {
6+
fun getBySlug(eventSlug: String): Settings?
7+
}

0 commit comments

Comments
 (0)