mastodon-ios/Mastodon/Service/APIService/APIService+Recommend.swift

82 lines
3.9 KiB
Swift
Raw Normal View History

2021-03-31 13:29:54 +02:00
//
// APIService+Recommend.swift
// Mastodon
//
// Created by sxiaojian on 2021/3/31.
//
import Combine
2021-03-31 13:29:54 +02:00
import Foundation
import MastodonSDK
import CoreData
import CoreDataStack
import OSLog
2021-03-31 13:29:54 +02:00
extension APIService {
2021-04-21 08:46:31 +02:00
func suggestionAccount(
domain: String,
query: Mastodon.API.Suggestions.Query?,
mastodonAuthenticationBox: MastodonAuthenticationBox
2021-04-21 08:46:31 +02:00
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Account]>, Error> {
fatalError()
// let authorization = mastodonAuthenticationBox.userAuthorization
//
// return Mastodon.API.Suggestions.get(session: session, domain: domain, query: query, authorization: authorization)
// .flatMap { response -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.Account]>, Error> in
// let log = OSLog.api
// return self.backgroundManagedObjectContext.performChanges {
// response.value.forEach { user in
// let (mastodonUser,isCreated) = APIService.CoreData.createOrMergeMastodonUser(into: self.backgroundManagedObjectContext, for: nil, in: domain, entity: user, userCache: nil, networkDate: Date(), log: log)
// let flag = isCreated ? "+" : "-"
// os_log(.info, log: log, "%{public}s[%{public}ld], %{public}s: fetch mastodon user [%s](%s)%s", (#file as NSString).lastPathComponent, #line, #function, flag, mastodonUser.id, mastodonUser.username)
// }
// }
// .setFailureType(to: Error.self)
// .tryMap { result -> Mastodon.Response.Content<[Mastodon.Entity.Account]> in
// switch result {
// case .success:
// return response
// case .failure(let error):
// throw error
// }
// }
// .eraseToAnyPublisher()
// }
// .eraseToAnyPublisher()
2021-04-21 08:46:31 +02:00
}
func suggestionAccountV2(
2021-03-31 13:29:54 +02:00
domain: String,
query: Mastodon.API.Suggestions.Query?,
mastodonAuthenticationBox: MastodonAuthenticationBox
2021-04-20 09:40:10 +02:00
) -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.V2.SuggestionAccount]>, Error> {
fatalError()
// let authorization = mastodonAuthenticationBox.userAuthorization
//
// return Mastodon.API.V2.Suggestions.get(session: session, domain: domain, query: query, authorization: authorization)
// .flatMap { response -> AnyPublisher<Mastodon.Response.Content<[Mastodon.Entity.V2.SuggestionAccount]>, Error> in
// let log = OSLog.api
// return self.backgroundManagedObjectContext.performChanges {
// response.value.forEach { suggestionAccount in
// let user = suggestionAccount.account
// let (mastodonUser,isCreated) = APIService.CoreData.createOrMergeMastodonUser(into: self.backgroundManagedObjectContext, for: nil, in: domain, entity: user, userCache: nil, networkDate: Date(), log: log)
// let flag = isCreated ? "+" : "-"
// os_log(.info, log: log, "%{public}s[%{public}ld], %{public}s: fetch mastodon user [%s](%s)%s", (#file as NSString).lastPathComponent, #line, #function, flag, mastodonUser.id, mastodonUser.username)
// }
// }
// .setFailureType(to: Error.self)
// .tryMap { result -> Mastodon.Response.Content<[Mastodon.Entity.V2.SuggestionAccount]> in
// switch result {
// case .success:
// return response
// case .failure(let error):
// throw error
// }
// }
// .eraseToAnyPublisher()
// }
// .eraseToAnyPublisher()
2021-03-31 13:29:54 +02:00
}
2021-03-31 13:29:54 +02:00
}