Skip to content

Commit e873892

Browse files
added ToS check in capabilities
Signed-off-by: Marino Faggiana <marino@marinofaggiana.com>
1 parent 63e0105 commit e873892

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

Sources/NextcloudKit/NKCommon.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ public struct NKCommon: Sendable {
411411
guard let groupDefaults = UserDefaults(suiteName: groupIdentifier) else {
412412
return
413413
}
414+
let capabilities = NCCapabilities.shared.getCapabilitiesBlocking(for: account)
414415

415416
/// Unavailable
416417
if errorCode == 503 {
@@ -429,7 +430,7 @@ public struct NKCommon: Sendable {
429430
groupDefaults.set(array, forKey: NextcloudKit.shared.nkCommonInstance.groupDefaultsUnauthorized)
430431
}
431432
/// ToS
432-
} else if errorCode == 403 {
433+
} else if errorCode == 403, capabilities.termsOfService {
433434
var array = groupDefaults.array(forKey: NextcloudKit.shared.nkCommonInstance.groupDefaultsToS) as? [String] ?? []
434435

435436
if !array.contains(account) {

Sources/NextcloudKit/NextcloudKitBackground.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public final class NKBackground: NSObject, URLSessionTaskDelegate, URLSessionDel
2121
var url: URL?
2222
let groupDefaults = UserDefaults(suiteName: NextcloudKit.shared.nkCommonInstance.groupIdentifier)
2323

24-
/// Check error in groupDefaults
24+
/// Check if error is in groupDefaults
2525
if let array = groupDefaults?.array(forKey: NextcloudKit.shared.nkCommonInstance.groupDefaultsUnauthorized) as? [String],
2626
array.contains(account) {
2727
return (nil, .unauthorizedError)
@@ -77,7 +77,7 @@ public final class NKBackground: NSObject, URLSessionTaskDelegate, URLSessionDel
7777
var uploadSession: URLSession?
7878
let groupDefaults = UserDefaults(suiteName: NextcloudKit.shared.nkCommonInstance.groupIdentifier)
7979

80-
/// Check error in groupDefaults
80+
/// Check if error is in groupDefaults
8181
if let array = groupDefaults?.array(forKey: NextcloudKit.shared.nkCommonInstance.groupDefaultsUnauthorized) as? [String],
8282
array.contains(account) {
8383
return (nil, .unauthorizedError)

0 commit comments

Comments
 (0)