Offer a home set that is itself a calendar as a task list (#180)
This commit is contained in:
1 parent
8cdf3ad709
commit
220c18170f
3 files changed
+68
-4
No files matched your search
@@ -96,6 +96,8 @@ All notable changes to this project are documented here. The format follows
|
||||
the next occurrence showed them already ticked. Unticking gives them back
|
||||
their state and dates, and repeating sub-tasks keep their own schedule
|
||||
(#160).
|
||||
- CalDAV accounts on servers that give each calendar its own account, such as
|
||||
all-inkl.com, find their task list instead of reporting none (#180).
|
||||
|
||||
## [1.3.1] - 2026-11-09
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package de.jeanlucmakiola.caldav
|
||||
|
||||
import at.bitfire.dav4jvm.DavResource
|
||||
import at.bitfire.dav4jvm.Response
|
||||
import at.bitfire.dav4jvm.UrlUtils
|
||||
import at.bitfire.dav4jvm.property.CalendarHomeSet
|
||||
import at.bitfire.dav4jvm.exception.HttpException
|
||||
import at.bitfire.dav4jvm.property.CurrentUserPrincipal
|
||||
@@ -319,9 +319,14 @@ class CalDavDiscovery(
|
||||
|
||||
for (homeSet in homeSets.distinct()) {
|
||||
val result = runCatching {
|
||||
DavResource(httpClient, homeSet).propfind(1, *collectionProperties) { response, relation ->
|
||||
if (relation == Response.HrefRelation.SELF) return@propfind
|
||||
CollectionClassifier.classify(response)?.let { collections[it.url] = it }
|
||||
// The home set itself is classified too: all-inkl.com reports its
|
||||
// one calendar as the home set (#180). A plain home collection is
|
||||
// not a calendar, so the classifier drops it as before. Keyed
|
||||
// slash-insensitively, since the self href may lack the slash.
|
||||
DavResource(httpClient, homeSet).propfind(1, *collectionProperties) { response, _ ->
|
||||
CollectionClassifier.classify(response)?.let {
|
||||
collections[UrlUtils.withTrailingSlash(it.url)] = it
|
||||
}
|
||||
}
|
||||
}
|
||||
result.fold(
|
||||
|
||||
@@ -245,6 +245,63 @@ class CalDavDiscoveryTest {
|
||||
assertThat(collections.single().isShared).isTrue()
|
||||
}
|
||||
|
||||
/** The all-inkl.com shape (#180): the home set is the account's one calendar. */
|
||||
private fun calendarAsHomeSet(componentSet: String, vararg members: String) = multistatus(
|
||||
"""
|
||||
<multistatus xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav">
|
||||
${collection("/calendars/user/1/", "<collection/><CAL:calendar/>", componentSet, displayName = "Kalender")}
|
||||
${members.joinToString("\n")}
|
||||
</multistatus>
|
||||
""".trimIndent(),
|
||||
)
|
||||
|
||||
private val eventsAndTasks = """<CAL:supported-calendar-component-set><CAL:comp name="VEVENT"/><CAL:comp name="VTODO"/></CAL:supported-calendar-component-set>"""
|
||||
|
||||
private val taskResource = """
|
||||
<response>
|
||||
<href>/calendars/user/1/0a1b2c.ics</href>
|
||||
<propstat><prop><resourcetype/></prop><status>HTTP/1.1 200 OK</status></propstat>
|
||||
</response>
|
||||
"""
|
||||
|
||||
@Test
|
||||
fun `a home set that is itself a calendar is offered as a list`() {
|
||||
server.enqueue(homeSetResponse("/calendars/user/1/"))
|
||||
server.enqueue(calendarAsHomeSet(eventsAndTasks, taskResource))
|
||||
|
||||
val found = discovery.fromPrincipal(server.url("/calendars/principals/user/")) as CalDavDiscovery.Outcome.Found
|
||||
assertThat(found.collections.map { it.url.encodedPath }).containsExactly("/calendars/user/1/")
|
||||
assertThat(found.collections.single().displayName).isEqualTo("Kalender")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a home set listed both as itself and as a member is offered once`() {
|
||||
server.enqueue(homeSetResponse("/calendars/user/1/"))
|
||||
server.enqueue(
|
||||
calendarAsHomeSet(
|
||||
eventsAndTasks,
|
||||
collection("/calendars/user/1", "<collection/><CAL:calendar/>", eventsAndTasks, displayName = "Kalender"),
|
||||
),
|
||||
)
|
||||
|
||||
val found = discovery.fromPrincipal(server.url("/calendars/principals/user/")) as CalDavDiscovery.Outcome.Found
|
||||
assertThat(found.collections.map { it.url.encodedPath.trimEnd('/') }).containsExactly("/calendars/user/1")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a home set that is a VEVENT-only calendar is not a list`() {
|
||||
server.enqueue(homeSetResponse("/calendars/user/1/"))
|
||||
server.enqueue(
|
||||
calendarAsHomeSet(
|
||||
"""<CAL:supported-calendar-component-set><CAL:comp name="VEVENT"/></CAL:supported-calendar-component-set>""",
|
||||
taskResource,
|
||||
),
|
||||
)
|
||||
|
||||
val found = discovery.fromPrincipal(server.url("/calendars/principals/user/")) as CalDavDiscovery.Outcome.Found
|
||||
assertThat(found.collections).isEmpty()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a principal with no home set is a failure worth naming`() {
|
||||
server.enqueue(homeSetResponse())
|
||||
|
||||
Reference in new issue
Block a user