Skip to content

Commit 4d9c527

Browse files
1 parent ce2d0c1 commit 4d9c527

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

readium/lcp/r2-lcp/src/main/java/org/readium/r2/lcp/service/DeviceService.kt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,19 @@ class DeviceService(private val repository: DeviceRepository, private val networ
4848
val registered = repository.isDeviceRegistered(license)
4949
if (registered) {
5050
completion(null)
51-
}
51+
} else {
52+
// TODO templated url
53+
val url = link.url(asQueryParameters).toString() ?: throw LCPError.licenseInteractionNotAvailable
5254

53-
// TODO templated url
54-
val url = link.url(asQueryParameters).toString() ?: throw LCPError.licenseInteractionNotAvailable
55+
network.fetch(url, method = NetworkService.Method.post, params = asQueryParameters) { status, data ->
56+
if (status != 200) {
57+
completion(null)
58+
}
5559

56-
network.fetch(url, method = NetworkService.Method.post, params = asQueryParameters) { status, data ->
57-
if (status != 200) {
58-
completion(null)
60+
repository.registerDevice(license)
61+
completion(data)
5962
}
60-
61-
repository.registerDevice(license)
62-
completion(data)
6363
}
64-
6564
}
6665
}
6766

0 commit comments

Comments
 (0)