From e87389279e88c36767f9c1d098f9d8b2c2d51268 Mon Sep 17 00:00:00 2001 From: Marino Faggiana Date: Tue, 17 Jun 2025 12:54:49 +0200 Subject: [PATCH] added ToS check in capabilities Signed-off-by: Marino Faggiana --- Sources/NextcloudKit/NKCommon.swift | 3 ++- Sources/NextcloudKit/NextcloudKitBackground.swift | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/NextcloudKit/NKCommon.swift b/Sources/NextcloudKit/NKCommon.swift index a2a56df4..598e8d2e 100644 --- a/Sources/NextcloudKit/NKCommon.swift +++ b/Sources/NextcloudKit/NKCommon.swift @@ -411,6 +411,7 @@ public struct NKCommon: Sendable { guard let groupDefaults = UserDefaults(suiteName: groupIdentifier) else { return } + let capabilities = NCCapabilities.shared.getCapabilitiesBlocking(for: account) /// Unavailable if errorCode == 503 { @@ -429,7 +430,7 @@ public struct NKCommon: Sendable { groupDefaults.set(array, forKey: NextcloudKit.shared.nkCommonInstance.groupDefaultsUnauthorized) } /// ToS - } else if errorCode == 403 { + } else if errorCode == 403, capabilities.termsOfService { var array = groupDefaults.array(forKey: NextcloudKit.shared.nkCommonInstance.groupDefaultsToS) as? [String] ?? [] if !array.contains(account) { diff --git a/Sources/NextcloudKit/NextcloudKitBackground.swift b/Sources/NextcloudKit/NextcloudKitBackground.swift index 32f07e9e..5ab72d2b 100644 --- a/Sources/NextcloudKit/NextcloudKitBackground.swift +++ b/Sources/NextcloudKit/NextcloudKitBackground.swift @@ -21,7 +21,7 @@ public final class NKBackground: NSObject, URLSessionTaskDelegate, URLSessionDel var url: URL? let groupDefaults = UserDefaults(suiteName: NextcloudKit.shared.nkCommonInstance.groupIdentifier) - /// Check error in groupDefaults + /// Check if error is in groupDefaults if let array = groupDefaults?.array(forKey: NextcloudKit.shared.nkCommonInstance.groupDefaultsUnauthorized) as? [String], array.contains(account) { return (nil, .unauthorizedError) @@ -77,7 +77,7 @@ public final class NKBackground: NSObject, URLSessionTaskDelegate, URLSessionDel var uploadSession: URLSession? let groupDefaults = UserDefaults(suiteName: NextcloudKit.shared.nkCommonInstance.groupIdentifier) - /// Check error in groupDefaults + /// Check if error is in groupDefaults if let array = groupDefaults?.array(forKey: NextcloudKit.shared.nkCommonInstance.groupDefaultsUnauthorized) as? [String], array.contains(account) { return (nil, .unauthorizedError)