2020-10-30 07:11:24 +00:00
|
|
|
// Copyright © 2020 Metabolist. All rights reserved.
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import GRDB
|
|
|
|
import Mastodon
|
|
|
|
|
|
|
|
struct NotificationRecord: ContentDatabaseRecord, Hashable {
|
|
|
|
let id: String
|
|
|
|
let type: MastodonNotification.NotificationType
|
|
|
|
let accountId: Account.Id
|
2021-01-27 02:31:00 +00:00
|
|
|
let createdAt: Date
|
2020-10-30 07:11:24 +00:00
|
|
|
let statusId: Status.Id?
|
|
|
|
}
|
|
|
|
|
|
|
|
extension NotificationRecord {
|
|
|
|
enum Columns {
|
2020-11-13 00:13:09 +00:00
|
|
|
static let id = Column(CodingKeys.id)
|
|
|
|
static let type = Column(CodingKeys.type)
|
|
|
|
static let accountId = Column(CodingKeys.accountId)
|
2021-01-27 02:31:00 +00:00
|
|
|
static let createdAt = Column(CodingKeys.createdAt)
|
2020-11-13 00:13:09 +00:00
|
|
|
static let statusId = Column(CodingKeys.statusId)
|
2020-10-30 07:11:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static let account = belongsTo(AccountRecord.self)
|
|
|
|
static let status = belongsTo(StatusRecord.self)
|
|
|
|
|
|
|
|
init(notification: MastodonNotification) {
|
|
|
|
id = notification.id
|
|
|
|
type = notification.type
|
|
|
|
accountId = notification.account.id
|
2021-01-27 02:31:00 +00:00
|
|
|
createdAt = notification.createdAt
|
2020-10-30 07:11:24 +00:00
|
|
|
statusId = notification.status?.id
|
|
|
|
}
|
|
|
|
}
|