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() await selectionFeedbackGenerator.selectionChanged()
let managedObjectContext = dependency.context.managedObjectContext let managedObjectContext = dependency.context.managedObjectContext
let _userID: MastodonUser.ID? = try await managedObjectContext.perform { let _userID: String? = try await managedObjectContext.perform {
return notification.account.id return notification.account.id
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -125,7 +125,7 @@ public final class AuthenticationService: NSObject {
extension AuthenticationService { 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 var isActive = false
AuthenticationServiceProvider.shared.activateAuthentication(in: domain, for: userID) AuthenticationServiceProvider.shared.activateAuthentication(in: domain, for: userID)