Use the same API for removing feeds Feedly web does and side step potential encoding issues. Attempt to fix #1691.

This commit is contained in:
Kiel Gillard 🤪 2020-05-20 12:22:34 +10:00
parent 4b1c40f264
commit 8d11ee6c82

View File

@ -281,14 +281,8 @@ final class FeedlyAPICaller {
}
}
guard let encodedFeedId = encodeForURLPath(feedId) else {
return DispatchQueue.main.async {
completion(.failure(FeedlyAccountDelegateError.unexpectedResourceId(feedId)))
}
}
var components = baseUrlComponents
components.percentEncodedPath = "/v3/collections/\(encodedCollectionId)/feeds/\(encodedFeedId)"
components.percentEncodedPath = "/v3/collections/\(encodedCollectionId)/feeds/.mdelete"
guard let url = components.url else {
fatalError("\(components) does not produce a valid URL.")
@ -300,6 +294,19 @@ final class FeedlyAPICaller {
request.addValue("application/json", forHTTPHeaderField: "Accept-Type")
request.addValue("OAuth \(accessToken)", forHTTPHeaderField: HTTPRequestHeader.authorization)
do {
struct RemovableFeed: Encodable {
let id: String
}
let encoder = JSONEncoder()
let data = try encoder.encode([RemovableFeed(id: feedId)])
request.httpBody = data
} catch {
return DispatchQueue.main.async {
completion(.failure(error))
}
}
transport.send(request: request, resultType: [FeedlyFeed].self, dateDecoding: .millisecondsSince1970, keyDecoding: .convertFromSnakeCase) { result in
switch result {
case .success((let httpResponse, _)):