package models

import "time"

// FollowUpTask is a reviewed, one-customer follow-up. DueAt is an operator
// reminder, never an instruction to the automatic campaign worker.
type FollowUpTask struct {
	ID          uint       `gorm:"primaryKey" json:"id"`
	AgentID     uint       `gorm:"not null;index:idx_followup_task_queue,priority:1;index:idx_followup_task_customer,priority:1" json:"agent_id"`
	Number      string     `gorm:"size:32;not null;index:idx_followup_task_customer,priority:2" json:"number"`
	Name        string     `gorm:"size:160" json:"name"`
	Reason      string     `gorm:"size:1000;not null" json:"reason"`
	Draft       string     `gorm:"type:text" json:"draft"`
	DueAt       time.Time  `gorm:"not null;index:idx_followup_task_queue,priority:3" json:"due_at"`
	Status      string     `gorm:"size:24;not null;index:idx_followup_task_queue,priority:2" json:"status"` // pending, sending, uncertain, completed, cancelled
	Source      string     `gorm:"size:16;not null" json:"source"`                                          // manual, ai
	SourceText  string     `gorm:"type:text" json:"source_text"`
	SourceKey   string     `gorm:"size:64;not null;uniqueIndex" json:"-"`
	Version     uint       `gorm:"not null;default:1" json:"version"`
	CreatedBy   uint       `json:"created_by"`
	CompletedBy uint       `json:"completed_by"`
	CompletedAt *time.Time `json:"completed_at,omitempty"`
	Outcome     string     `gorm:"size:40" json:"outcome"`
	WAMsgID     string     `gorm:"size:64" json:"wa_msg_id,omitempty"`
	CreatedAt   time.Time  `json:"created_at"`
	UpdatedAt   time.Time  `json:"updated_at"`
}
