// NKSC1-c8c7ea42327292095dea8150adbebc85-0708f3a4174e426d0d2ad28718b26adb4894e3d58893d8e7340ae63a514fbf41

package models

import "time"

// One durable notice per handoff. The same WhatsApp message ID is reused on
// retry, including recovery after a worker restart. No customer chat is created.
type HandoffNotification struct {
	ID            uint       `gorm:"primaryKey" json:"id"`
	AgentID       uint       `gorm:"not null;index" json:"-"`
	HandoffID     uint       `gorm:"not null;uniqueIndex" json:"handoff_id"`
	Recipient     string     `gorm:"size:32;not null" json:"-"`
	Message       string     `gorm:"type:text;not null" json:"-"`
	MessageID     string     `gorm:"size:64;not null" json:"-"`
	Status        string     `gorm:"size:16;not null;index" json:"status"`
	Attempts      int        `gorm:"not null;default:0" json:"attempts"`
	NextAttemptAt *time.Time `gorm:"index" json:"next_attempt_at,omitempty"`
	LockedUntil   *time.Time `json:"-"`
	LockToken     string     `gorm:"size:64" json:"-"`
	LastError     string     `gorm:"size:255" json:"last_error,omitempty"`
	CreatedAt     time.Time  `json:"created_at"`
	SentAt        *time.Time `json:"sent_at,omitempty"`
}
