Skip to content

Commit

Permalink
[buteo-sync-plugins-social] Handle Google downsynced all day event ex…
Browse files Browse the repository at this point in the history
…ceptions. Contributes to JB#52954

For Google calendar sync, if an exception for a recurring all day event
is downsynced from the server, the exception must be added to the rule
as a date, rather than a dateTime. Otherwise the exception fails to be
applied to the local calendar.
  • Loading branch information
llewelld committed Feb 5, 2021
1 parent 22aac88 commit b05a089
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions src/google/google-calendars/googlecalendarsyncadaptor.cpp
Expand Up @@ -385,8 +385,16 @@ QJsonArray recurrenceArray(KCalendarCore::Event::Ptr event, KCalendarCore::ICalF

QDateTime parseRecurrenceId(const QJsonObject &originalStartTime)
{
QString recurrenceIdStr = originalStartTime.value(QLatin1String("dateTime")).toVariant().toString();
QString recurrenceIdTzStr = originalStartTime.value(QLatin1String("timeZone")).toVariant().toString();
QString recurrenceIdStr;
QString recurrenceIdTzStr;

if (originalStartTime.contains(QLatin1String("date"))) {
recurrenceIdStr = originalStartTime.value(QLatin1String("date")).toVariant().toString();
} else {
recurrenceIdStr = originalStartTime.value(QLatin1String("dateTime")).toVariant().toString();
recurrenceIdTzStr = originalStartTime.value(QLatin1String("timeZone")).toVariant().toString();
}

QDateTime recurrenceId = QDateTime::fromString(recurrenceIdStr, Qt::ISODate);
if (!recurrenceIdTzStr.isEmpty()) {
recurrenceId = recurrenceId.toTimeZone(QTimeZone(recurrenceIdTzStr.toLatin1()));
Expand Down Expand Up @@ -2622,9 +2630,17 @@ bool GoogleCalendarSyncAdaptor::applyRemoteDeleteOccurence(const QString &eventI
SOCIALD_LOG_DEBUG("Occurrence deleted remotely:" << eventId << "for recurrenceId:" << recurrenceId.toString());
KCalendarCore::Event::Ptr event = allLocalEventsMap.value(parentId);
if (event) {
event->startUpdates();
event->recurrence()->addExDateTime(recurrenceId);
event->endUpdates();
if (recurrenceId.isValid()) {
event->startUpdates();
if (event->allDay()) {
event->recurrence()->addExDate(recurrenceId.date());
} else {
event->recurrence()->addExDateTime(recurrenceId);
}
event->endUpdates();
} else {
flagDeleteFailure(event->uid());
}
} else {
// The parent event should never be null by this point, but we guard against it just in case
SOCIALD_LOG_ERROR("Deletion failed as the parent event" << parentId << "couldn't be found");
Expand Down

0 comments on commit b05a089

Please sign in to comment.