import Foundation

struct Message: Identifiable, Equatable {
    let id: String
    let conversationId: String
    let senderId: String
    var senderUsername: String
    let createdAt: Date
    var text: String?
    var replyTo: String?
    var imageFileId: String?
    var file: FileInfo?
    var isDeleted: Bool
    var readBy: Set<String>

    /// Whether this is a self-sent message
    func isMine(currentUserId: String) -> Bool {
        senderId == currentUserId
    }

    static func == (lhs: Message, rhs: Message) -> Bool {
        lhs.id == rhs.id
    }
}

struct FileInfo: Equatable, Codable {
    let fileId: String
    let aesKey: String   // hex
    let iv: String       // hex
    let filename: String
    let size: Int
    let mimeType: String
}
