Skip to content

Commit d835bc1

Browse files
committed
Fix build warnings
1 parent b1a795e commit d835bc1

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

libpretixsync/src/main/java/eu/pretix/libpretixsync/sync/OrderSyncAdapter.kt

+16-16
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class OrderSyncAdapter(
112112
}
113113
}
114114

115-
private fun preparePositionObject(obj: OrderPosition?, jsonobj: JSONObject, orderId: Long, jsonorder: JSONObject, parent: JSONObject?): OrderPosition {
115+
private fun preparePositionObject(jsonobj: JSONObject, orderId: Long, jsonorder: JSONObject, parent: JSONObject?): OrderPosition {
116116
val jsonName = if (jsonobj.isNull("attendee_name")) "" else jsonobj.optString("attendee_name")
117117
// TODO: BUG: jsonName can never be null, so parent / jInvoiceAddress is never used
118118
// Keeping old behaviour for compatibility
@@ -157,7 +157,7 @@ class OrderSyncAdapter(
157157
}
158158

159159
private fun insertPositionObject(jsonobj: JSONObject, orderId: Long, jsonorder: JSONObject, parent: JSONObject?) {
160-
val posobj = preparePositionObject(null, jsonobj, orderId, jsonorder, parent)
160+
val posobj = preparePositionObject(jsonobj, orderId, jsonorder, parent)
161161

162162
val id = db.orderPositionQueries.transactionWithResult {
163163
db.orderPositionQueries.insert(
@@ -180,7 +180,7 @@ class OrderSyncAdapter(
180180
}
181181

182182
private fun updatePositionObject(obj: OrderPosition, jsonobj: JSONObject, orderId: Long, jsonorder: JSONObject, parent: JSONObject?) {
183-
val posobj = preparePositionObject(obj, jsonobj, orderId, jsonorder, parent)
183+
val posobj = preparePositionObject(jsonobj, orderId, jsonorder, parent)
184184

185185
db.orderPositionQueries.updateFromJson(
186186
attendee_email = posobj.attendee_email,
@@ -359,26 +359,26 @@ class OrderSyncAdapter(
359359
override fun deleteUnseen(): Boolean = false
360360

361361
override fun downloadPage(url: String, isFirstPage: Boolean): JSONObject? {
362-
var url = url
363362
if (isFirstPage) {
364363
rlm = db.resourceSyncStatusQueries.selectByResourceAndEventSlug(
365364
resource = rlmName(),
366365
event_slug = eventSlug,
367366
).executeAsOneOrNull()
368367
}
369368
var is_continued_fetch = false
370-
if (!url.contains("testmode=")) {
371-
url += if (url.contains("?")) {
369+
var resUrl = url
370+
if (!resUrl.contains("testmode=")) {
371+
resUrl += if (resUrl.contains("?")) {
372372
"&"
373373
} else {
374374
"?"
375375
}
376-
url += "testmode=false&exclude=downloads&exclude=payment_date&exclude=payment_provider&exclude=fees&exclude=positions.downloads"
376+
resUrl += "testmode=false&exclude=downloads&exclude=payment_date&exclude=payment_provider&exclude=fees&exclude=positions.downloads"
377377
if (!isPretixpos) {
378-
url += "&exclude=payments&exclude=refunds"
378+
resUrl += "&exclude=payments&exclude=refunds"
379379
}
380380
if (withPdfData) {
381-
url += "&pdf_data=true"
381+
resUrl += "&pdf_data=true"
382382
}
383383
}
384384

@@ -408,8 +408,8 @@ class OrderSyncAdapter(
408408

409409
is_continued_fetch = true
410410
try {
411-
if (!url.contains("created_since")) {
412-
url += "&ordering=datetime&created_since=" + URLEncoder.encode(resourceSyncStatus.status.substring(11), "UTF-8") + firstrun_params
411+
if (!resUrl.contains("created_since")) {
412+
resUrl += "&ordering=datetime&created_since=" + URLEncoder.encode(resourceSyncStatus.status.substring(11), "UTF-8") + firstrun_params
413413
}
414414
} catch (e: UnsupportedEncodingException) {
415415
e.printStackTrace()
@@ -429,20 +429,20 @@ class OrderSyncAdapter(
429429
// of the first page.
430430

431431
try {
432-
if (!url.contains("modified_since")) {
433-
url += "&ordering=-last_modified&modified_since=" + URLEncoder.encode(resourceSyncStatus.last_modified, "UTF-8")
432+
if (!resUrl.contains("modified_since")) {
433+
resUrl += "&ordering=-last_modified&modified_since=" + URLEncoder.encode(resourceSyncStatus.last_modified, "UTF-8")
434434
}
435435
} catch (e: UnsupportedEncodingException) {
436436
e.printStackTrace()
437437
}
438438
}
439439
} else {
440-
if (!url.contains("subevent_after")) {
441-
url += firstrun_params
440+
if (!resUrl.contains("subevent_after")) {
441+
resUrl += firstrun_params
442442
}
443443
}
444444

445-
val apiResponse = api.fetchResource(url)
445+
val apiResponse = api.fetchResource(resUrl)
446446
if (isFirstPage && !is_continued_fetch) {
447447
firstResponseTimestamp = apiResponse.response.header("X-Page-Generated")
448448
}

0 commit comments

Comments
 (0)