This commit is contained in:
Justin Mazzocchi 2020-12-02 21:18:47 -08:00
parent a6d959a6b9
commit ea8462f26b
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
3 changed files with 12 additions and 12 deletions

View File

@ -4,22 +4,22 @@ import Foundation
import HTTP
import Mastodon
public enum DeletionEndpoint {
public enum EmptyEndpoint {
case oauthRevoke(token: String, clientId: String, clientSecret: String)
case list(id: List.Id)
case filter(id: Filter.Id)
case deleteList(id: List.Id)
case deleteFilter(id: Filter.Id)
}
extension DeletionEndpoint: Endpoint {
extension EmptyEndpoint: Endpoint {
public typealias ResultType = [String: String]
public var context: [String] {
switch self {
case .oauthRevoke:
return ["oauth"]
case .list:
case .deleteList:
return defaultContext + ["lists"]
case .filter:
case .deleteFilter:
return defaultContext + ["filters"]
}
}
@ -28,7 +28,7 @@ extension DeletionEndpoint: Endpoint {
switch self {
case .oauthRevoke:
return ["revoke"]
case let .list(id), let .filter(id):
case let .deleteList(id), let .deleteFilter(id):
return [id]
}
}
@ -37,7 +37,7 @@ extension DeletionEndpoint: Endpoint {
switch self {
case .oauthRevoke:
return .post
case .list, .filter:
case .deleteList, .deleteFilter:
return .delete
}
}
@ -46,7 +46,7 @@ extension DeletionEndpoint: Endpoint {
switch self {
case let .oauthRevoke(token, clientId, clientSecret):
return ["token": token, "client_id": clientId, "client_secret": clientSecret]
case .list, .filter:
case .deleteList, .deleteFilter:
return nil
}
}

View File

@ -99,7 +99,7 @@ public extension AllIdentitiesService {
return MastodonAPIClient(
session: environment.session,
instanceURL: try secrets.getInstanceURL())
.request(DeletionEndpoint.oauthRevoke(
.request(EmptyEndpoint.oauthRevoke(
token: try secrets.getAccessToken(),
clientId: try secrets.getClientId(),
clientSecret: try secrets.getClientSecret()))

View File

@ -87,7 +87,7 @@ public extension IdentityService {
}
func deleteList(id: List.Id) -> AnyPublisher<Never, Error> {
mastodonAPIClient.request(DeletionEndpoint.list(id: id))
mastodonAPIClient.request(EmptyEndpoint.deleteList(id: id))
.map { _ in id }
.flatMap(contentDatabase.deleteList(id:))
.eraseToAnyPublisher()
@ -152,7 +152,7 @@ public extension IdentityService {
}
func deleteFilter(id: Filter.Id) -> AnyPublisher<Never, Error> {
mastodonAPIClient.request(DeletionEndpoint.filter(id: id))
mastodonAPIClient.request(EmptyEndpoint.deleteFilter(id: id))
.flatMap { _ in contentDatabase.deleteFilter(id: id) }
.eraseToAnyPublisher()
}