2020-09-05 01:06:21 +00:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import GRDB
|
|
|
|
import Mastodon
|
|
|
|
|
2020-10-14 00:28:27 +00:00
|
|
|
struct AccountRecord: ContentDatabaseRecord, Hashable {
|
2020-10-05 22:50:05 +00:00
|
|
|
let id: Account.Id
|
2020-09-05 01:06:21 +00:00
|
|
|
let username: String
|
|
|
|
let acct: String
|
|
|
|
let displayName: String
|
|
|
|
let locked: Bool
|
|
|
|
let createdAt: Date
|
|
|
|
let followersCount: Int
|
|
|
|
let followingCount: Int
|
|
|
|
let statusesCount: Int
|
|
|
|
let note: HTML
|
|
|
|
let url: URL
|
|
|
|
let avatar: URL
|
|
|
|
let avatarStatic: URL
|
|
|
|
let header: URL
|
|
|
|
let headerStatic: URL
|
|
|
|
let fields: [Account.Field]
|
|
|
|
let emojis: [Emoji]
|
|
|
|
let bot: Bool
|
|
|
|
let discoverable: Bool
|
2020-10-05 22:50:05 +00:00
|
|
|
let movedId: Account.Id?
|
2020-09-05 01:06:21 +00:00
|
|
|
}
|
|
|
|
|
2020-09-29 06:06:25 +00:00
|
|
|
extension AccountRecord {
|
|
|
|
enum Columns {
|
2020-11-13 00:13:09 +00:00
|
|
|
static let id = Column(CodingKeys.id)
|
|
|
|
static let username = Column(CodingKeys.username)
|
|
|
|
static let acct = Column(CodingKeys.acct)
|
|
|
|
static let displayName = Column(CodingKeys.displayName)
|
|
|
|
static let locked = Column(CodingKeys.locked)
|
|
|
|
static let createdAt = Column(CodingKeys.createdAt)
|
|
|
|
static let followersCount = Column(CodingKeys.followersCount)
|
|
|
|
static let followingCount = Column(CodingKeys.followingCount)
|
|
|
|
static let statusesCount = Column(CodingKeys.statusesCount)
|
|
|
|
static let note = Column(CodingKeys.note)
|
|
|
|
static let url = Column(CodingKeys.url)
|
|
|
|
static let avatar = Column(CodingKeys.avatar)
|
|
|
|
static let avatarStatic = Column(CodingKeys.avatarStatic)
|
|
|
|
static let header = Column(CodingKeys.header)
|
|
|
|
static let headerStatic = Column(CodingKeys.headerStatic)
|
|
|
|
static let fields = Column(CodingKeys.fields)
|
|
|
|
static let emojis = Column(CodingKeys.emojis)
|
|
|
|
static let bot = Column(CodingKeys.bot)
|
|
|
|
static let discoverable = Column(CodingKeys.discoverable)
|
|
|
|
static let movedId = Column(CodingKeys.movedId)
|
2020-09-29 06:06:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-05 02:05:15 +00:00
|
|
|
extension AccountRecord {
|
2020-09-29 23:44:31 +00:00
|
|
|
static let moved = belongsTo(AccountRecord.self)
|
2020-11-11 07:31:56 +00:00
|
|
|
static let relationship = hasOne(Relationship.self)
|
|
|
|
static let identityProofs = hasMany(IdentityProofRecord.self)
|
2021-01-18 07:17:45 +00:00
|
|
|
static let featuredTags = hasMany(FeaturedTagRecord.self)
|
2020-09-29 23:44:31 +00:00
|
|
|
static let pinnedStatusJoins = hasMany(AccountPinnedStatusJoin.self)
|
2021-01-31 15:49:09 +00:00
|
|
|
.order(AccountPinnedStatusJoin.Columns.order)
|
2020-09-18 00:16:41 +00:00
|
|
|
static let pinnedStatuses = hasMany(
|
|
|
|
StatusRecord.self,
|
|
|
|
through: pinnedStatusJoins,
|
|
|
|
using: AccountPinnedStatusJoin.status)
|
|
|
|
|
2020-09-29 23:56:09 +00:00
|
|
|
var pinnedStatuses: QueryInterfaceRequest<StatusInfo> {
|
|
|
|
StatusInfo.request(request(for: Self.pinnedStatuses))
|
2020-09-18 00:16:41 +00:00
|
|
|
}
|
2020-09-05 01:06:21 +00:00
|
|
|
|
|
|
|
init(account: Account) {
|
|
|
|
id = account.id
|
|
|
|
username = account.username
|
|
|
|
acct = account.acct
|
|
|
|
displayName = account.displayName
|
|
|
|
locked = account.locked
|
|
|
|
createdAt = account.createdAt
|
|
|
|
followersCount = account.followersCount
|
|
|
|
followingCount = account.followingCount
|
|
|
|
statusesCount = account.statusesCount
|
|
|
|
note = account.note
|
|
|
|
url = account.url
|
|
|
|
avatar = account.avatar
|
|
|
|
avatarStatic = account.avatarStatic
|
|
|
|
header = account.header
|
|
|
|
headerStatic = account.headerStatic
|
|
|
|
fields = account.fields
|
|
|
|
emojis = account.emojis
|
|
|
|
bot = account.bot
|
|
|
|
discoverable = account.discoverable
|
|
|
|
movedId = account.moved?.id
|
|
|
|
}
|
|
|
|
}
|