fix: CalDAV Nextcloud — fallback principals/users/ pour calendar-home-set (v0.0.2)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ android {
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
versionCode = 1
|
||||
versionName = "0.0.1"
|
||||
versionName = "0.0.2"
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
|
||||
@@ -94,10 +94,20 @@ class CalDavDiscovery @Inject constructor(private val client: CalDavClient) {
|
||||
</propfind>
|
||||
""".trimIndent()
|
||||
|
||||
val resp = client.propfind(principalUrl, credentials, "0", body)
|
||||
if (!resp.isSuccess) return null
|
||||
val href = extractHref(resp.body, "calendar-home-set") ?: return null
|
||||
return resolveUrl(principalUrl, href)
|
||||
val urlsToTry = mutableListOf(principalUrl)
|
||||
// Nextcloud alias /principals/username/ doesn't expose calendar-home-set,
|
||||
// but /principals/users/username/ does — add it as fallback
|
||||
if (principalUrl.contains("/principals/") && !principalUrl.contains("/principals/users/")) {
|
||||
urlsToTry.add(principalUrl.replaceFirst("/principals/", "/principals/users/"))
|
||||
}
|
||||
|
||||
for (url in urlsToTry) {
|
||||
val resp = client.propfind(url, credentials, "0", body)
|
||||
if (!resp.isSuccess) continue
|
||||
val href = extractHref(resp.body, "calendar-home-set") ?: continue
|
||||
return resolveUrl(url, href)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
private fun listCalendars(homeUrl: String, credentials: String, username: String, baseUrl: String): List<CalendarInfo> {
|
||||
|
||||
Reference in New Issue
Block a user