Replace MastodonUser.ID with string (IOS-192)

This commit is contained in:
Nathan Mattes 2023-12-13 16:42:35 +01:00
parent 9046b8b8c8
commit f51d5b7fe2
11 changed files with 26 additions and 28 deletions

View File

@ -56,7 +56,7 @@ extension DataSourceFacade {
await selectionFeedbackGenerator.selectionChanged()
let managedObjectContext = dependency.context.managedObjectContext
let _userID: MastodonUser.ID? = try await managedObjectContext.perform {
let _userID: String? = try await managedObjectContext.perform {
return notification.account.id
}

View File

@ -11,15 +11,13 @@ import Foundation
/// See also `CoreDataStack.MastodonUser`, this extension contains several
@available(*, deprecated, message: "Replace with Mastodon.Entity.Account")
final public class MastodonUser: NSManagedObject {
public typealias ID = String
// sourcery: autoGenerateProperty
@NSManaged public private(set) var identifier: ID
@NSManaged public private(set) var identifier: String
// sourcery: autoGenerateProperty
@NSManaged public private(set) var domain: String
// sourcery: autoGenerateProperty
@NSManaged public private(set) var id: ID
@NSManaged public private(set) var id: String
// sourcery: autoUpdatableObject, autoGenerateProperty
@NSManaged public private(set) var acct: String
@ -206,11 +204,11 @@ extension MastodonUser {
])
}
public static func predicate(followingBy userID: MastodonUser.ID) -> NSPredicate {
public static func predicate(followingBy userID: String) -> NSPredicate {
NSPredicate(format: "ANY %K.%K == %@", #keyPath(MastodonUser.followingBy), #keyPath(MastodonUser.id), userID)
}
public static func predicate(followRequestedBy userID: MastodonUser.ID) -> NSPredicate {
public static func predicate(followRequestedBy userID: String) -> NSPredicate {
NSPredicate(format: "ANY %K.%K == %@", #keyPath(MastodonUser.followRequestedBy), #keyPath(MastodonUser.id), userID)
}
@ -223,9 +221,9 @@ extension MastodonUser: AutoGenerateProperty {
// Generated using Sourcery
// DO NOT EDIT
public struct Property {
public let identifier: ID
public let identifier: String
public let domain: String
public let id: ID
public let id: String
public let acct: String
public let username: String
public let displayName: String
@ -247,9 +245,9 @@ extension MastodonUser: AutoGenerateProperty {
public let fields: [MastodonField]
public init(
identifier: ID,
identifier: String,
domain: String,
id: ID,
id: String,
acct: String,
username: String,
displayName: String,

View File

@ -64,7 +64,7 @@ public final class Status: NSManagedObject {
// sourcery: autoUpdatableObject, autoGenerateProperty
@NSManaged public private(set) var inReplyToID: Status.ID?
// sourcery: autoUpdatableObject, autoGenerateProperty
@NSManaged public private(set) var inReplyToAccountID: MastodonUser.ID?
@NSManaged public private(set) var inReplyToAccountID: String?
// sourcery: autoUpdatableObject, autoGenerateProperty
@NSManaged public private(set) var language: String? // (ISO 639 Part 1 two-letter language code)
@ -270,7 +270,7 @@ extension Status: AutoGenerateProperty {
public let repliesCount: Int64
public let url: String?
public let inReplyToID: Status.ID?
public let inReplyToAccountID: MastodonUser.ID?
public let inReplyToAccountID: String?
public let language: String?
public let text: String?
public let updatedAt: Date
@ -295,7 +295,7 @@ extension Status: AutoGenerateProperty {
repliesCount: Int64,
url: String?,
inReplyToID: Status.ID?,
inReplyToAccountID: MastodonUser.ID?,
inReplyToAccountID: String?,
language: String?,
text: String?,
updatedAt: Date,
@ -484,7 +484,7 @@ extension Status: AutoUpdatableObject {
self.inReplyToID = inReplyToID
}
}
public func update(inReplyToAccountID: MastodonUser.ID?) {
public func update(inReplyToAccountID: String?) {
if self.inReplyToAccountID != inReplyToAccountID {
self.inReplyToAccountID = inReplyToAccountID
}

View File

@ -11,7 +11,7 @@ import Foundation
extension Feed {
public enum Acct: RawRepresentable {
case none
case mastodon(domain: String, userID: MastodonUser.ID)
case mastodon(domain: String, userID: String)
public init?(rawValue: String) {
let components = rawValue.split(separator: "@", maxSplits: 2)

View File

@ -12,7 +12,7 @@ import MastodonSDK
public struct MastodonAuthenticationBox: UserIdentifier {
public let authentication: MastodonAuthentication
public let domain: String
public let userID: MastodonUser.ID
public let userID: String
public let appAuthorization: Mastodon.API.OAuth.Authorization
public let userAuthorization: Mastodon.API.OAuth.Authorization
public let inMemoryCache: MastodonAccountInMemoryCache
@ -20,7 +20,7 @@ public struct MastodonAuthenticationBox: UserIdentifier {
public init(
authentication: MastodonAuthentication,
domain: String,
userID: MastodonUser.ID,
userID: String,
appAuthorization: Mastodon.API.OAuth.Authorization,
userAuthorization: Mastodon.API.OAuth.Authorization,
inMemoryCache: MastodonAccountInMemoryCache

View File

@ -14,7 +14,7 @@ extension Notification.Property {
public init(
entity: Mastodon.Entity.Notification,
domain: String,
userID: MastodonUser.ID,
userID: String,
networkDate: Date
) {
self.init(

View File

@ -14,8 +14,8 @@ import MastodonSDK
extension APIService {
private struct MastodonBlockContext {
let sourceUserID: MastodonUser.ID
let targetUserID: MastodonUser.ID
let sourceUserID: String
let targetUserID: String
let targetUsername: String
let isBlocking: Bool
let isFollowing: Bool

View File

@ -14,8 +14,8 @@ import MastodonSDK
extension APIService {
private struct MastodonFollowContext {
let sourceUserID: MastodonUser.ID
let targetUserID: MastodonUser.ID
let sourceUserID: String
let targetUserID: String
let isFollowing: Bool
let isPending: Bool
let needsUnfollow: Bool

View File

@ -14,7 +14,7 @@ import MastodonSDK
extension APIService {
private struct MastodonMuteContext {
let targetUserID: MastodonUser.ID
let targetUserID: String
let targetUsername: String
let isMuting: Bool
}

View File

@ -20,7 +20,7 @@ extension APIService {
let managedObjectContext = backgroundManagedObjectContext
let _query: Mastodon.API.Account.RelationshipQuery? = try? await managedObjectContext.perform {
var ids: [MastodonUser.ID] = []
var ids: [String] = []
for record in records {
guard let user = record.object(in: managedObjectContext) else { continue }
guard user.id != authenticationBox.userID else { continue }
@ -71,7 +71,7 @@ extension APIService {
authenticationBox: MastodonAuthenticationBox
) async throws -> Mastodon.Response.Content<[Mastodon.Entity.Relationship]> {
let ids: [MastodonUser.ID] = accounts.compactMap { $0.id }
let ids: [String] = accounts.compactMap { $0.id }
guard ids.isEmpty == false else { throw APIError.implicit(.badRequest) }

View File

@ -125,7 +125,7 @@ public final class AuthenticationService: NSObject {
extension AuthenticationService {
public func activeMastodonUser(domain: String, userID: MastodonUser.ID) async throws -> Bool {
public func activeMastodonUser(domain: String, userID: String) async throws -> Bool {
var isActive = false
AuthenticationServiceProvider.shared.activateAuthentication(in: domain, for: userID)