From c40496c308791ee3a2f6173840c08b3d2fb445a0 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Mon, 3 Aug 2026 15:21:39 -0700 Subject: [PATCH] =?UTF-8?q?Remove=20the=20redundant=20Feedly=20status-code?= =?UTF-8?q?=20guards=20=E2=80=94=20the=20transport=20already=20validates,?= =?UTF-8?q?=20so=20they=20could=20only=20reject=20successful=20responses?= =?UTF-8?q?=20like=20a=20204.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Account/Feedly/FeedlyAPICaller.swift | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Modules/Account/Sources/Account/Feedly/FeedlyAPICaller.swift b/Modules/Account/Sources/Account/Feedly/FeedlyAPICaller.swift index 1061f67f5..7b1c750d5 100644 --- a/Modules/Account/Sources/Account/Feedly/FeedlyAPICaller.swift +++ b/Modules/Account/Sources/Account/Feedly/FeedlyAPICaller.swift @@ -121,8 +121,8 @@ extension FeedlyAPICaller { var request = try makeAuthorizedRequest(path: "/v3/collections", method: HTTPMethod.post) request.httpBody = try JSONEncoder().encode(CreateCollectionBody(label: label)) - let (httpResponse, collections) = try await send(request: request, resultType: [FeedlyCollection].self, dateDecoding: .millisecondsSince1970, keyDecoding: .convertFromSnakeCase) - guard httpResponse.statusCode == 200, let collection = collections?.first else { + let (_, collections) = try await send(request: request, resultType: [FeedlyCollection].self, dateDecoding: .millisecondsSince1970, keyDecoding: .convertFromSnakeCase) + guard let collection = collections?.first else { throw URLError(.cannotDecodeContentData) } return collection @@ -137,8 +137,8 @@ extension FeedlyAPICaller { var request = try makeAuthorizedRequest(path: "/v3/collections", method: HTTPMethod.post) request.httpBody = try JSONEncoder().encode(RenameCollectionBody(id: id, label: name)) - let (httpResponse, collections) = try await send(request: request, resultType: [FeedlyCollection].self, dateDecoding: .millisecondsSince1970, keyDecoding: .convertFromSnakeCase) - guard httpResponse.statusCode == 200, let collection = collections?.first else { + let (_, collections) = try await send(request: request, resultType: [FeedlyCollection].self, dateDecoding: .millisecondsSince1970, keyDecoding: .convertFromSnakeCase) + guard let collection = collections?.first else { throw URLError(.cannotDecodeContentData) } return collection @@ -150,10 +150,7 @@ extension FeedlyAPICaller { } let request = try makeAuthorizedRequest(percentEncodedPath: "/v3/collections/\(encodedID)", method: HTTPMethod.delete) - let (httpResponse, _) = try await send(request: request, resultType: Optional.self, dateDecoding: .millisecondsSince1970, keyDecoding: .convertFromSnakeCase) - guard httpResponse.statusCode == 200 else { - throw URLError(.cannotDecodeContentData) - } + _ = try await sendIgnoringResponseBody(request: request) } func addFeed(with feedID: FeedlyFeedResourceID, title: String? = nil, toCollectionWith collectionID: String) async throws -> [FeedlyFeed] { @@ -186,12 +183,7 @@ extension FeedlyAPICaller { var request = try makeAuthorizedRequest(percentEncodedPath: "/v3/collections/\(encodedCollectionID)/feeds/.mdelete", method: HTTPMethod.delete) request.httpBody = try JSONEncoder().encode([RemovableFeed(id: feedID)]) - // `resultType` is optional because the Feedly API has gone from returning an array of removed feeds to returning `null`. - // https://developer.feedly.com/v3/collections/#remove-multiple-feeds-from-a-personal-collection - let (httpResponse, _) = try await send(request: request, resultType: Optional<[FeedlyFeed]>.self, dateDecoding: .millisecondsSince1970, keyDecoding: .convertFromSnakeCase) - guard httpResponse.statusCode == 200 else { - throw URLError(.cannotDecodeContentData) - } + _ = try await sendIgnoringResponseBody(request: request) } } @@ -277,10 +269,7 @@ extension FeedlyAPICaller { // The markers response body is irrelevant to success — decoding it could // turn a successful mark into a spurious failure that requeues forever. - let httpResponse = try await sendIgnoringResponseBody(request: request) - guard (200...299).contains(httpResponse.statusCode) else { - throw WebserviceError.httpError(status: httpResponse.statusCode) - } + _ = try await sendIgnoringResponseBody(request: request) } }