|
|
|
|
@ -6,7 +6,7 @@ final class RemindersService: RemindersServicing {
|
|
|
|
|
func list(params: OpenClawRemindersListParams) async throws -> OpenClawRemindersListPayload {
|
|
|
|
|
let store = EKEventStore()
|
|
|
|
|
let status = EKEventStore.authorizationStatus(for: .reminder)
|
|
|
|
|
let authorized = await Self.ensureAuthorization(store: store, status: status)
|
|
|
|
|
let authorized = EventKitAuthorization.allowsRead(status: status)
|
|
|
|
|
guard authorized else {
|
|
|
|
|
throw NSError(domain: "Reminders", code: 1, userInfo: [
|
|
|
|
|
NSLocalizedDescriptionKey: "REMINDERS_PERMISSION_REQUIRED: grant Reminders permission",
|
|
|
|
|
@ -50,7 +50,7 @@ final class RemindersService: RemindersServicing {
|
|
|
|
|
func add(params: OpenClawRemindersAddParams) async throws -> OpenClawRemindersAddPayload {
|
|
|
|
|
let store = EKEventStore()
|
|
|
|
|
let status = EKEventStore.authorizationStatus(for: .reminder)
|
|
|
|
|
let authorized = await Self.ensureWriteAuthorization(store: store, status: status)
|
|
|
|
|
let authorized = EventKitAuthorization.allowsWrite(status: status)
|
|
|
|
|
guard authorized else {
|
|
|
|
|
throw NSError(domain: "Reminders", code: 2, userInfo: [
|
|
|
|
|
NSLocalizedDescriptionKey: "REMINDERS_PERMISSION_REQUIRED: grant Reminders permission",
|
|
|
|
|
@ -100,38 +100,6 @@ final class RemindersService: RemindersServicing {
|
|
|
|
|
return OpenClawRemindersAddPayload(reminder: payload)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static func ensureAuthorization(store: EKEventStore, status: EKAuthorizationStatus) async -> Bool {
|
|
|
|
|
switch status {
|
|
|
|
|
case .authorized:
|
|
|
|
|
return true
|
|
|
|
|
case .notDetermined:
|
|
|
|
|
// Don’t prompt during node.invoke; prompts block the invoke and lead to timeouts.
|
|
|
|
|
return false
|
|
|
|
|
case .restricted, .denied:
|
|
|
|
|
return false
|
|
|
|
|
case .fullAccess:
|
|
|
|
|
return true
|
|
|
|
|
case .writeOnly:
|
|
|
|
|
return false
|
|
|
|
|
@unknown default:
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static func ensureWriteAuthorization(store: EKEventStore, status: EKAuthorizationStatus) async -> Bool {
|
|
|
|
|
switch status {
|
|
|
|
|
case .authorized, .fullAccess, .writeOnly:
|
|
|
|
|
return true
|
|
|
|
|
case .notDetermined:
|
|
|
|
|
// Don’t prompt during node.invoke; prompts block the invoke and lead to timeouts.
|
|
|
|
|
return false
|
|
|
|
|
case .restricted, .denied:
|
|
|
|
|
return false
|
|
|
|
|
@unknown default:
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static func resolveList(
|
|
|
|
|
store: EKEventStore,
|
|
|
|
|
listId: String?,
|
|
|
|
|
|