package entities

import (
	"time"

	"github.com/google/uuid"
)

type LetterDiscussion struct {
	ID        uuid.UUID  `gorm:"type:uuid;primary_key;default:gen_random_uuid()" json:"id"`
	LetterID  uuid.UUID  `gorm:"type:uuid;not null" json:"letter_id"`
	ParentID  *uuid.UUID `json:"parent_id,omitempty"`
	UserID    uuid.UUID  `gorm:"type:uuid;not null" json:"user_id"`
	Message   string     `gorm:"not null" json:"message"`
	Mentions  JSONB      `gorm:"type:jsonb" json:"mentions,omitempty"`
	CreatedAt time.Time  `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt time.Time  `gorm:"autoUpdateTime" json:"updated_at"`
	EditedAt  *time.Time `json:"edited_at,omitempty"`

	// Relationships
	User *User `gorm:"foreignKey:UserID;references:ID" json:"user,omitempty"`
}

func (LetterDiscussion) TableName() string { return "letter_incoming_discussions" }
