another.im-ios/ConversationsClassic/AppCore/Models/Attachment.swift

37 lines
824 B
Swift
Raw Normal View History

2024-07-09 12:37:51 +00:00
import Foundation
import GRDB
import Martin
import SwiftUI
2024-07-10 11:09:59 +00:00
enum AttachmentType: Int, Stateable, DatabaseValueConvertible {
case movie = 0
case image = 1
case audio = 2
case file = 3
case location = 4
case contact = 5
2024-07-09 12:37:51 +00:00
}
2024-07-10 11:09:59 +00:00
struct AttachmentItem: DBStorable {
static let databaseTableName = "attachment_items"
let id: String
static let attachment = belongsTo(Attachment.self)
2024-07-09 13:13:37 +00:00
let type: AttachmentType
2024-07-10 11:09:59 +00:00
let localPath: URL?
let remotePath: URL?
let localThumbnailPath: URL?
let string: String?
2024-07-09 13:13:37 +00:00
}
2024-07-10 11:09:59 +00:00
struct Attachment: DBStorable {
static let databaseTableName = "attachments"
2024-07-09 12:37:51 +00:00
let id: String
2024-07-10 11:09:59 +00:00
static let items = hasMany(AttachmentItem.self)
static let message = hasOne(Message.self)
2024-07-09 12:37:51 +00:00
}
2024-07-10 11:09:59 +00:00
extension AttachmentItem: Equatable {}
extension Attachment: Equatable {}