Skip to content

Commit

Permalink
Use cached notebook email info
Browse files Browse the repository at this point in the history
  • Loading branch information
pvuorela committed May 22, 2019
1 parent c397856 commit 90f6348
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/calendarworker.cpp
Expand Up @@ -421,12 +421,19 @@ bool NemoCalendarWorker::needSendCancellation(KCalCore::Event::Ptr &event) const
return false;
}
// we shouldn't send a response if we are not an organizer
if (calOrganizer->email() != mKCal::ServiceHandler::instance().emailAddress(mStorage->notebook(mCalendar->notebook(event)), mStorage)) {
if (calOrganizer->email() != getNotebookAddress(event)) {
return false;
}
return true;
}

QString NemoCalendarWorker::getNotebookAddress(const KCalCore::Event::Ptr &event) const
{
const QString &notebookUid = mCalendar->notebook(event);
return mNotebooks.contains(notebookUid) ? mNotebooks.value(notebookUid).emailAddress
: QString();
}

QList<NemoCalendarData::Notebook> NemoCalendarWorker::notebooks() const
{
return mNotebooks.values();
Expand Down Expand Up @@ -663,8 +670,8 @@ NemoCalendarData::Event NemoCalendarWorker::createEventStruct(const KCalCore::Ev
event.recur = NemoCalendarUtils::convertRecurrence(e);

KCalCore::Attendee::List attendees = e->attendees();
const QString &calendarOwnerEmail = mNotebooks.contains(event.calendarUid) ? mNotebooks.value(event.calendarUid).emailAddress
: QString();
const QString &calendarOwnerEmail = getNotebookAddress(e);

foreach (KCalCore::Attendee::Ptr calAttendee, attendees) {
if (calAttendee->email() == calendarOwnerEmail) {
event.ownerStatus = NemoCalendarUtils::convertPartStat(calAttendee->status());
Expand Down Expand Up @@ -770,7 +777,8 @@ QList<NemoCalendarData::Attendee> NemoCalendarWorker::getEventAttendees(const QS
return result;
}

return NemoCalendarUtils::getEventAttendees(event, mKCal::ServiceHandler::instance().emailAddress(mStorage->notebook(mCalendar->notebook(event)), mStorage));
const QString &ownerEmail = getNotebookAddress(event);
return NemoCalendarUtils::getEventAttendees(event, ownerEmail);
}

void NemoCalendarWorker::findMatchingEvent(const QString &invitationFile)
Expand Down
1 change: 1 addition & 0 deletions src/calendarworker.h
Expand Up @@ -116,6 +116,7 @@ public slots:
bool setRecurrence(KCalCore::Event::Ptr &event, NemoCalendarEvent::Recur recur);
bool setReminder(KCalCore::Event::Ptr &event, int reminderSeconds);
bool needSendCancellation(KCalCore::Event::Ptr &event) const;
QString getNotebookAddress(const KCalCore::Event::Ptr &event) const;

NemoCalendarData::Event createEventStruct(const KCalCore::Event::Ptr &event) const;
QHash<QString, NemoCalendarData::EventOccurrence> eventOccurrences(const QList<NemoCalendarData::Range> &ranges) const;
Expand Down

0 comments on commit 90f6348

Please sign in to comment.