1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import Foundation
protocol BlueskyService {
func restoreAccount() async throws -> Account?
func restoreAccount(onLocalAccount: @MainActor @Sendable (String) -> Void) async throws -> Account?
func signIn(handle: String, appPassword: String, authFactorToken: String?) async throws -> Account
func signOut() async throws
func loadFollowingFeed(cursor: String?) async throws -> FeedPage
func searchAccounts(query: String, cursor: String?) async throws -> AccountSearchPage
func suggestAccounts(query: String) async throws -> [Post.Author]
func searchPosts(query: String, cursor: String?, authorID: String?) async throws -> FeedPage
func loadSubscribedFeeds() async throws -> [CustomFeed]
func loadCustomFeed(uri: String, cursor: String?) async throws -> FeedPage
func loadNotifications(cursor: String?) async throws -> NotificationPage
func markNotificationsRead(seenAt: Date) async throws
func loadPost(uri: String) async throws -> [Post]
func loadThread(uri: String) async throws -> ThreadResult
func loadProfile(actorID: String) async throws -> Profile?
func loadProfileConnections(actorID: String, kind: ProfileConnectionKind, cursor: String?) async throws
-> ProfileConnectionsPage
func loadProfileEdit(accountID: String) async throws -> EditableProfile
func saveProfileEdit(_ draft: ProfileEdit, original: EditableProfile, accountID: String) async throws
-> ProfileEditResult
func loadAuthorPosts(actorID: String, cursor: String?) async throws -> FeedPage
func loadSavedPosts(cursor: String?) async throws -> FeedPage
func setPostSaved(_ saved: Bool, post: Post) async throws
func toggleLike(post: Post, liked: Bool) async throws -> String?
func toggleRepost(post: Post, reposted: Bool) async throws -> String?
func deletePost(_ post: Post) async throws
func publish(text: String, replyTo: Post?, quotePost: Post?, images: [ImageAttachment]) async throws -> Post
func publish(text: String, replyTo: Post?, quotePost: Post?, images: [ImageAttachment], video: VideoAttachment?)
async throws -> Post
func loadDrafts(cursor: String?) async throws -> SavedPostDraftPage
func loadDraft(id: String) async throws -> ComposerDraft
func saveDraft(_ draft: ComposerDraft, id: String?) async throws -> String
func deleteDraft(id: String) async throws
func setFollowing(_ following: Bool, actorID: String) async throws -> String?
func loadModerationPreferences() async throws -> ModerationPolicy.Preferences
func moderationState(actorID: String) async throws -> ModerationState
func setMuted(_ muted: Bool, actorID: String) async throws
func setBlocked(_ blocked: Bool, actorID: String, blockURI: String?) async throws -> String?
func report(_ subject: ReportSubject, reason: String) async throws
}
extension BlueskyService {
func restoreAccount(onLocalAccount: @MainActor @Sendable (String) -> Void) async throws -> Account? {
try await restoreAccount()
}
func loadProfileConnections(actorID: String, kind: ProfileConnectionKind, cursor: String?) async throws
-> ProfileConnectionsPage {
throw ServiceError.invalidResponse
}
func loadProfileEdit(accountID: String) async throws -> EditableProfile { throw ServiceError.profileUnavailable }
func saveProfileEdit(_ draft: ProfileEdit, original: EditableProfile, accountID: String) async throws
-> ProfileEditResult {
throw ServiceError.profileUnavailable
}
func loadSavedPosts(cursor: String?) async throws -> FeedPage { throw ServiceError.invalidResponse }
func setPostSaved(_ saved: Bool, post: Post) async throws { throw ServiceError.invalidResponse }
func loadDrafts(cursor: String?) async throws -> SavedPostDraftPage {
throw SavedPostDraftError.unavailable("Drafts are unavailable. Try again.")
}
func loadDraft(id: String) async throws -> ComposerDraft {
throw SavedPostDraftError.unavailable("This draft is unavailable. Try again.")
}
func saveDraft(_ draft: ComposerDraft, id: String?) async throws -> String {
throw SavedPostDraftError.unavailable("The draft could not be saved. Try again.")
}
func deleteDraft(id: String) async throws {
throw SavedPostDraftError.unavailable("The draft could not be deleted. Try again.")
}
func publish(text: String, replyTo: Post?, quotePost: Post?, images: [ImageAttachment], video: VideoAttachment?)
async throws -> Post {
guard video == nil else { throw ServiceError.videoUploadUnavailable }
return try await publish(text: text, replyTo: replyTo, quotePost: quotePost, images: images)
}
func suggestAccounts(query: String) async throws -> [Post.Author] {
try await searchAccounts(query: query, cursor: nil).accounts
}
func searchAccounts(query: String, cursor: String?) async throws -> AccountSearchPage {
throw ServiceError.invalidResponse
}
func searchPosts(query: String, cursor: String?, authorID: String? = nil) async throws -> FeedPage {
throw ServiceError.invalidResponse
}
func loadSubscribedFeeds() async throws -> [CustomFeed] { [] }
func loadCustomFeed(uri: String, cursor: String?) async throws -> FeedPage { throw CustomFeedError.unavailable }
func deletePost(_ post: Post) async throws { throw ServiceError.invalidResponse }
func loadModerationPreferences() async throws -> ModerationPolicy.Preferences { throw ServiceError.invalidResponse }
func moderationState(actorID: String) async throws -> ModerationState { throw ServiceError.invalidResponse }
func setMuted(_ muted: Bool, actorID: String) async throws { throw ServiceError.invalidResponse }
func setBlocked(_ blocked: Bool, actorID: String, blockURI: String?) async throws -> String? {
throw ServiceError.invalidResponse
}
func report(_ subject: ReportSubject, reason: String) async throws { throw ServiceError.invalidResponse }
func loadThread(uri: String) async throws -> ThreadResult {
ThreadResult(posts: try await loadPost(uri: uri), mutedPostIDs: [])
}
}