import Foundation
import SwiftData

@Model class SavedMessage {
    #Index<SavedMessage>([\.buffer, \.timestamp])

    var buffer: String
    var senderId: String?
    var senderName: String
    var content: String
    var timestamp: Date
    var isSystem: Bool = false
    var senderIsRecipient: Bool = false
    var characterId: String?
    var sessionId: UUID

    init(
        buffer: String,
        senderId: String?,
        senderName: String,
        content: String,
        timestamp: Date = .now,
        isSystem: Bool = false,
        senderIsRecipient: Bool = false,
        characterId: String? = nil,
        sessionId: UUID
    ) {
        self.buffer = buffer
        self.senderId = senderId
        self.senderName = senderName
        self.content = content
        self.timestamp = timestamp
        self.isSystem = isSystem
        self.senderIsRecipient = senderIsRecipient
        self.characterId = characterId
        self.sessionId = sessionId
    }
}
