Skip to content

Commit 1c60e71

Browse files
committed
Add comments
1 parent 496a783 commit 1c60e71

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import java.util.UUID
5050
/**
5151
* Mapper from Android event main + data rows to [VEvent].
5252
*
53-
* @param accountName account name (used to generate self-attendee)
53+
* @param accountName account name (used to generate reminder email address)
5454
* @param prodIdGenerator generates the `PRODID` to use
5555
*/
5656
class AndroidEventProcessor(
@@ -210,7 +210,14 @@ class AndroidEventProcessor(
210210

211211
val groupScheduled = main.subValues.any { it.uri == CalendarContract.Attendees.CONTENT_URI }
212212
if (groupScheduled) {
213-
val weAreOrganizer = mainValues.getAsInteger(Events.IS_ORGANIZER) == 1
213+
/* Note: Events.IS_ORGANIZER is defined in CalendarDatabaseHelper.java as
214+
COALESCE(Events.IS_ORGANIZER, Events.ORGANIZER = Calendars.OWNER_ACCOUNT), so it's non-null when it's
215+
- either explicitly set for an event,
216+
- or the event's ORGANIZER is the same as the calendar's OWNER_ACCOUNT. */
217+
val weAreOrganizer = when (mainValues.getAsInteger(Events.IS_ORGANIZER)) {
218+
null, 0 -> false
219+
/* explicitly set to non-zero, or 1 by provider calculation */ else -> true
220+
}
214221

215222
return if (weAreOrganizer) {
216223
/* Upload of a group-scheduled event and we are the organizer, so we increase the SEQUENCE.

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ class OrganizerProcessor: AndroidEventFieldProcessor {
2222
get() = Logger.getLogger(javaClass.name)
2323

2424
override fun process(from: Entity, main: Entity, to: VEvent) {
25-
// In case of an exception, we're taking ORGANIZER information from the main event and not the exception. See also RFC 6638 3.1.
26-
val values = main.entityValues
25+
// In case of an exception, we're taking ORGANIZER information from the main event and not the exception.
26+
// See also RFC 6638 3.1 and 3.2.4.2.
27+
val mainValues = main.entityValues
2728

2829
// ORGANIZER must only be set for group-scheduled events (= events with attendees)
2930
val hasAttendees = from.subValues.any { it.uri == Attendees.CONTENT_URI }
30-
if (hasAttendees && values.containsKey(Events.ORGANIZER))
31+
if (hasAttendees && mainValues.containsKey(Events.ORGANIZER))
3132
try {
32-
to.properties += Organizer(URI("mailto", values.getAsString(Events.ORGANIZER), null))
33+
to.properties += Organizer(URI("mailto", mainValues.getAsString(Events.ORGANIZER), null))
3334
} catch (e: URISyntaxException) {
3435
logger.log(Level.WARNING, "Error when creating ORGANIZER mailto URI, ignoring", e)
3536
}

0 commit comments

Comments
 (0)