Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Set recurrence start time when converting…
Browse files Browse the repository at this point in the history
… from json. Contributes to JB#51507

The recurrence rules store the event start time separately from the
event itself. If set incorrectly (or not at all) the rules end up being
badly formed, and other actions (e.g. dissociating event exceptions)
could fail.

Events extracted from the database have recurrence start times
automatically set to the event start time, but this wasn't happening
during json deserialisation. This change adds it in.

The issue was triggered when an update for the main event was received
from google (resulting in a json deserialisation), followed in the same
sync by a new recurrence exception for the same event. In this case, the
dissociation for the recurrence was failing due to the lack of start
time in the recurrence rule. If the changes were received in separate
syncs the problem didn't arise, since the main event had been "washed"
through the database.
  • Loading branch information
llewelld committed Nov 26, 2020
1 parent 970beac commit 92d6b82
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/google/google-calendars/googlecalendarsyncadaptor.cpp
Expand Up @@ -520,6 +520,8 @@ void extractRecurrence(const QJsonArray &recurrence, KCalCore::Event::Ptr event,
SOCIALD_LOG_DEBUG("unable to parse RRULE information:" << ruleStr);
traceDumpStr(QString::fromUtf8(QJsonDocument(recurrence).toJson()));
} else {
// Set the recurrence start to be the event start
rrule->setStartDt(event->dtStart());
kcalRecurrence->addRRule(rrule);
}
} else if (ruleStr.startsWith(QString::fromLatin1("exrule"), Qt::CaseInsensitive)) {
Expand Down Expand Up @@ -765,7 +767,6 @@ void jsonToKCal(const QJsonObject &json, KCalCore::Event::Ptr event, int default
setGCalETag(event, jsonGCalETag);
}
setRemoteUidCustomField(event, json.value(QLatin1String("iCalUID")).toVariant().toString(), json.value(QLatin1String("id")).toVariant().toString());
extractRecurrence(json.value(QLatin1String("recurrence")).toArray(), event, icalFormat, exceptions);
extractOrganizer(json.value(QLatin1String("creator")).toObject(), json.value(QLatin1String("organizer")).toObject(), event);
extractAttendees(json.value(QLatin1String("attendees")).toArray(), event);
UPDATE_EVENT_PROPERTY_IF_REQUIRED(event, isReadOnly, setReadOnly, json.value(QLatin1String("locked")).toVariant().toBool(), changed)
Expand All @@ -791,6 +792,8 @@ void jsonToKCal(const QJsonObject &json, KCalCore::Event::Ptr event, int default
} else {
UPDATE_EVENT_PROPERTY_IF_REQUIRED(event, hasEndDate, setHasEndDate, false, changed)
}
// Recurrence rules use the event start time, so must be set after it
extractRecurrence(json.value(QLatin1String("recurrence")).toArray(), event, icalFormat, exceptions);
if (isAllDay) {
UPDATE_EVENT_PROPERTY_IF_REQUIRED(event, allDay, setAllDay, true, changed)
}
Expand Down

0 comments on commit 92d6b82

Please sign in to comment.