// NKSC1-c8c7ea42327292095dea8150adbebc85-0708f3a4174e426d0d2ad28718b26adb4894e3d58893d8e7340ae63a514fbf41

package models

import "time"

// A receipt belongs to a login and one scheduled occurrence. Snoozing the alert
// never changes the customer's DueAt or completes the task.
type FollowUpReminderReceipt struct {
	ID           uint      `gorm:"primaryKey"`
	Key          string    `gorm:"size:64;not null;uniqueIndex"`
	TaskID       uint      `gorm:"not null;index"`
	AgentID      uint      `gorm:"not null;index"`
	UserID       uint      `gorm:"not null;index"`
	OccurrenceAt time.Time `gorm:"not null;index"`
	NotifiedAt   *time.Time
	SnoozedUntil *time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

// Independent opt-in: installing reminders must not enable external delivery.
type FollowUpNotificationSetting struct {
	AgentID      uint      `gorm:"primaryKey" json:"-"`
	Enabled      bool      `gorm:"not null;default:false" json:"enabled"`
	Number       string    `gorm:"size:32" json:"number"`
	DashboardURL string    `gorm:"size:512" json:"dashboard_url"`
	EnabledAt    time.Time `json:"-"`
	UpdatedAt    time.Time `json:"-"`
}

// Persist the message ID before the side effect. Unknown outcomes are never
// retried blindly. No customer transcript or draft is copied into this table.
type FollowUpNotificationDelivery struct {
	ID           uint       `gorm:"primaryKey" json:"id"`
	Key          string     `gorm:"size:64;not null;uniqueIndex" json:"-"`
	TaskID       uint       `gorm:"not null;index" json:"task_id"`
	AgentID      uint       `gorm:"not null;index" json:"-"`
	OccurrenceAt time.Time  `gorm:"not null;index" json:"-"`
	Recipient    string     `gorm:"size:32" json:"-"`
	MessageID    string     `gorm:"size:64;index" json:"-"`
	Status       string     `gorm:"size:24" json:"status"`
	SentAt       *time.Time `json:"sent_at,omitempty"`
	CreatedAt    time.Time  `json:"created_at"`
	UpdatedAt    time.Time  `json:"-"`
}
