package models

import "time"

// ConversationWork tracks the operator for one chat, independently from the
// account's access to a WhatsApp number. History imports do not create timers.
type ConversationWork struct {
	ID             uint       `gorm:"primaryKey" json:"id"`
	AgentID        uint       `gorm:"not null;uniqueIndex:idx_conversation_work,priority:1;index" json:"agent_id"`
	Sender         string     `gorm:"size:32;not null;uniqueIndex:idx_conversation_work,priority:2" json:"sender"`
	AssignedUserID uint       `gorm:"not null;default:0;index" json:"assigned_user_id"`
	Status         string     `gorm:"size:16;not null;default:open" json:"status"`
	LastIncomingAt *time.Time `json:"last_incoming_at,omitempty"`
	LastResponseAt *time.Time `json:"last_response_at,omitempty"`
	WaitingSince   *time.Time `json:"waiting_since,omitempty"`
	DueAt          *time.Time `gorm:"index" json:"due_at,omitempty"`
	ResolvedAt     *time.Time `json:"resolved_at,omitempty"`
	Version        uint       `gorm:"not null;default:1" json:"version"`
	CreatedAt      time.Time  `json:"created_at"`
	UpdatedAt      time.Time  `json:"updated_at"`
}
