2020-11-11 07:31:56 +00:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import GRDB
|
|
|
|
import Mastodon
|
|
|
|
|
|
|
|
struct ProfileInfo: Codable, Hashable, FetchableRecord {
|
|
|
|
let accountInfo: AccountInfo
|
|
|
|
let relationship: Relationship?
|
|
|
|
let identityProofRecords: [IdentityProofRecord]
|
2021-01-18 07:17:45 +00:00
|
|
|
let featuredTagRecords: [FeaturedTagRecord]
|
2020-11-11 07:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
extension ProfileInfo {
|
|
|
|
static func addingIncludes<T: DerivableRequest>(_ request: T) -> T where T.RowDecoder == AccountRecord {
|
|
|
|
AccountInfo.addingIncludes(request)
|
|
|
|
.including(optional: AccountRecord.relationship.forKey(CodingKeys.relationship))
|
|
|
|
.including(all: AccountRecord.identityProofs.forKey(CodingKeys.identityProofRecords))
|
2021-01-18 07:17:45 +00:00
|
|
|
.including(all: AccountRecord.featuredTags.forKey(CodingKeys.featuredTagRecords))
|
2020-11-11 07:31:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static func request(_ request: QueryInterfaceRequest<AccountRecord>) -> QueryInterfaceRequest<Self> {
|
|
|
|
addingIncludes(request).asRequest(of: self)
|
|
|
|
}
|
|
|
|
}
|