mirror of
https://github.com/metabolist/metatext.git
synced 2024-11-22 00:01:00 +00:00
Renaming
This commit is contained in:
parent
a6d959a6b9
commit
ea8462f26b
3 changed files with 12 additions and 12 deletions
|
@ -4,22 +4,22 @@ import Foundation
|
||||||
import HTTP
|
import HTTP
|
||||||
import Mastodon
|
import Mastodon
|
||||||
|
|
||||||
public enum DeletionEndpoint {
|
public enum EmptyEndpoint {
|
||||||
case oauthRevoke(token: String, clientId: String, clientSecret: String)
|
case oauthRevoke(token: String, clientId: String, clientSecret: String)
|
||||||
case list(id: List.Id)
|
case deleteList(id: List.Id)
|
||||||
case filter(id: Filter.Id)
|
case deleteFilter(id: Filter.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
extension DeletionEndpoint: Endpoint {
|
extension EmptyEndpoint: Endpoint {
|
||||||
public typealias ResultType = [String: String]
|
public typealias ResultType = [String: String]
|
||||||
|
|
||||||
public var context: [String] {
|
public var context: [String] {
|
||||||
switch self {
|
switch self {
|
||||||
case .oauthRevoke:
|
case .oauthRevoke:
|
||||||
return ["oauth"]
|
return ["oauth"]
|
||||||
case .list:
|
case .deleteList:
|
||||||
return defaultContext + ["lists"]
|
return defaultContext + ["lists"]
|
||||||
case .filter:
|
case .deleteFilter:
|
||||||
return defaultContext + ["filters"]
|
return defaultContext + ["filters"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ extension DeletionEndpoint: Endpoint {
|
||||||
switch self {
|
switch self {
|
||||||
case .oauthRevoke:
|
case .oauthRevoke:
|
||||||
return ["revoke"]
|
return ["revoke"]
|
||||||
case let .list(id), let .filter(id):
|
case let .deleteList(id), let .deleteFilter(id):
|
||||||
return [id]
|
return [id]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ extension DeletionEndpoint: Endpoint {
|
||||||
switch self {
|
switch self {
|
||||||
case .oauthRevoke:
|
case .oauthRevoke:
|
||||||
return .post
|
return .post
|
||||||
case .list, .filter:
|
case .deleteList, .deleteFilter:
|
||||||
return .delete
|
return .delete
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ extension DeletionEndpoint: Endpoint {
|
||||||
switch self {
|
switch self {
|
||||||
case let .oauthRevoke(token, clientId, clientSecret):
|
case let .oauthRevoke(token, clientId, clientSecret):
|
||||||
return ["token": token, "client_id": clientId, "client_secret": clientSecret]
|
return ["token": token, "client_id": clientId, "client_secret": clientSecret]
|
||||||
case .list, .filter:
|
case .deleteList, .deleteFilter:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -99,7 +99,7 @@ public extension AllIdentitiesService {
|
||||||
return MastodonAPIClient(
|
return MastodonAPIClient(
|
||||||
session: environment.session,
|
session: environment.session,
|
||||||
instanceURL: try secrets.getInstanceURL())
|
instanceURL: try secrets.getInstanceURL())
|
||||||
.request(DeletionEndpoint.oauthRevoke(
|
.request(EmptyEndpoint.oauthRevoke(
|
||||||
token: try secrets.getAccessToken(),
|
token: try secrets.getAccessToken(),
|
||||||
clientId: try secrets.getClientId(),
|
clientId: try secrets.getClientId(),
|
||||||
clientSecret: try secrets.getClientSecret()))
|
clientSecret: try secrets.getClientSecret()))
|
||||||
|
|
|
@ -87,7 +87,7 @@ public extension IdentityService {
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteList(id: List.Id) -> AnyPublisher<Never, Error> {
|
func deleteList(id: List.Id) -> AnyPublisher<Never, Error> {
|
||||||
mastodonAPIClient.request(DeletionEndpoint.list(id: id))
|
mastodonAPIClient.request(EmptyEndpoint.deleteList(id: id))
|
||||||
.map { _ in id }
|
.map { _ in id }
|
||||||
.flatMap(contentDatabase.deleteList(id:))
|
.flatMap(contentDatabase.deleteList(id:))
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
|
@ -152,7 +152,7 @@ public extension IdentityService {
|
||||||
}
|
}
|
||||||
|
|
||||||
func deleteFilter(id: Filter.Id) -> AnyPublisher<Never, Error> {
|
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) }
|
.flatMap { _ in contentDatabase.deleteFilter(id: id) }
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue