Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ class ExternalControlActivity : Activity(), CoroutineScope by MainScope() {
}
val name = uri.getQueryParameter("name") ?: getString(R.string.new_profile)

val parsedInterval = uri.getQueryParameter("update-interval")?.toLongOrNull() ?: 0L
val updateInterval = if (parsedInterval > 0) parsedInterval.coerceAtLeast(15L) else 0L
val intervalMs = java.util.concurrent.TimeUnit.MINUTES.toMillis(updateInterval)

create(type, name).also {
patch(it, name, url, 0)
patch(it, name, url, intervalMs)
}
}
startActivity(PropertiesActivity::class.intent.setUUID(uuid))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ object ProfileProcessor {
var download: Long = 0
var total: Long = 0
var expire: Long = 0
var updateInterval: Long = snapshot.interval
if (snapshot?.type == Profile.Type.Url) {
if (snapshot.source.startsWith("https://", true)) {
val client = OkHttpClient()
Expand Down Expand Up @@ -103,14 +104,27 @@ object ProfileProcessor {
}
}
}

val updateIntervalHeader = response.headers["profile-update-interval"]
if (response.isSuccessful && updateIntervalHeader != null) {
val intervalHours = updateIntervalHeader.toLongOrNull()
if (intervalHours != null) {
updateInterval = if (intervalHours > 0) {
java.util.concurrent.TimeUnit.HOURS.toMillis(intervalHours)
.coerceAtLeast(java.util.concurrent.TimeUnit.MINUTES.toMillis(15))
} else {
0L
}
}
}
}
}
val new = Imported(
snapshot.uuid,
snapshot.name,
snapshot.type,
snapshot.source,
snapshot.interval,
updateInterval,
upload,
download,
total,
Expand Down
Loading