Skip to content

Commit 5a36e32

Browse files
committed
Completly ignore exceptions without original instance time (RECURRENCE-ID)
1 parent 7e00cbf commit 5a36e32

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

lib/src/androidTest/kotlin/at/bitfire/synctools/mapping/calendar/LegacyAndroidEventProcessorTest.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,4 +1023,30 @@ class LegacyAndroidEventProcessorTest {
10231023
}
10241024
}
10251025

1026+
@Test
1027+
fun testPopulateException_Exdate_NoRecurrenceId() {
1028+
populateException({
1029+
put(Events._SYNC_ID, "testPopulateException_AllDay")
1030+
put(Events.TITLE, "Recurring all-day event with cancelled exception and no RECURRENCE-ID")
1031+
put(Events.DTSTART, 1594056600000L)
1032+
put(Events.EVENT_TIMEZONE, tzVienna.id)
1033+
put(Events.ALL_DAY, 0)
1034+
put(Events.RRULE, "FREQ=DAILY;COUNT=10")
1035+
}, {
1036+
put(Events.ORIGINAL_SYNC_ID, "testPopulateException_AllDay")
1037+
//put(Events.ORIGINAL_INSTANCE_TIME, 1594143000000L)
1038+
put(Events.ORIGINAL_ALL_DAY, 0)
1039+
put(Events.DTSTART, 1594143000000L)
1040+
put(Events.ALL_DAY, 0)
1041+
put(Events.EVENT_TIMEZONE, tzShanghai.id)
1042+
put(Events.STATUS, Events.STATUS_CANCELED)
1043+
}).let { event ->
1044+
assertEquals("Recurring all-day event with cancelled exception and no RECURRENCE-ID", event.summary)
1045+
assertEquals(DtStart("20200706T193000", tzVienna), event.dtStart)
1046+
assertEquals("FREQ=DAILY;COUNT=10", event.rRules.first().value)
1047+
assertTrue(event.exDates.isEmpty())
1048+
assertTrue(event.exceptions.isEmpty())
1049+
}
1050+
}
1051+
10261052
}

lib/src/main/kotlin/at/bitfire/synctools/mapping/calendar/LegacyAndroidEventProcessor.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,14 @@ class LegacyAndroidEventProcessor(
409409
for (exception in exceptions) {
410410
val exceptionEvent = Event()
411411

412+
// exceptions are required to have a RECURRENCE-ID
413+
val recurrenceId = exceptionEvent.recurrenceId ?: continue
414+
412415
// convert exception row to Event
413416
populateEvent(exception, to = exceptionEvent)
414417

415418
// generate EXDATE instead of RECURRENCE-ID exceptions for cancelled instances
416-
val recurrenceId = exceptionEvent.recurrenceId
417-
if (exceptionEvent.status == Status.VEVENT_CANCELLED && recurrenceId != null) {
419+
if (exceptionEvent.status == Status.VEVENT_CANCELLED) {
418420
val list = DateList(
419421
if (DateUtils.isDate(recurrenceId)) Value.DATE else Value.DATE_TIME,
420422
recurrenceId.timeZone

0 commit comments

Comments
 (0)