Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Sources/EventKitManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,24 @@ class EventKitManager {
dict["hasAlarms"] = event.hasAlarms
dict["hasRecurrenceRules"] = event.hasRecurrenceRules

if let attendees = event.attendees, !attendees.isEmpty {
dict["attendees"] = attendees.map { participant -> [String: Any] in
var entry: [String: Any] = [
"name": participant.name ?? "",
"status": participantStatusString(participant.participantStatus),
"role": participantRoleString(participant.participantRole),
]
// EKParticipant email is encoded in the URL as mailto:
let url = participant.url
if url.scheme == "mailto" {
entry["email"] = url.absoluteString.replacingOccurrences(of: "mailto:", with: "")
}
return entry
}
} else {
dict["attendees"] = [] as [[String: Any]]
}

return dict
}

Expand Down Expand Up @@ -418,6 +436,31 @@ class EventKitManager {
}
}

// MARK: - EKParticipant Helpers

private func participantStatusString(_ status: EKParticipantStatus) -> String {
switch status {
case .accepted: return "accepted"
case .declined: return "declined"
case .tentative: return "tentative"
case .pending: return "pending"
case .delegated: return "delegated"
case .completed: return "completed"
case .inProcess: return "inProcess"
default: return "unknown"
}
}

private func participantRoleString(_ role: EKParticipantRole) -> String {
switch role {
case .required: return "required"
case .optional: return "optional"
case .chair: return "chair"
case .nonParticipant: return "nonParticipant"
default: return "unknown"
}
}

// MARK: - CGColor Extension for Hex String

import CoreGraphics
Expand Down