// NKSC1-c8c7ea42327292095dea8150adbebc85-0708f3a4174e426d0d2ad28718b26adb4894e3d58893d8e7340ae63a514fbf41

package models

import "time"

// Label = label WhatsApp (Business) yang disinkron dari event app-state.
type Label struct {
	ID        uint      `gorm:"primaryKey" json:"id"`
	AgentID   uint      `gorm:"not null;uniqueIndex:idx_label_agent,priority:1" json:"agent_id"`
	LabelID   string    `gorm:"size:64;not null;uniqueIndex:idx_label_agent,priority:2" json:"label_id"`
	Name      string    `json:"name"`
	Color     int       `json:"color"`
	UpdatedAt time.Time `json:"updated_at"`
}

// ChatLabel = relasi kontak <-> label (chat yang diberi label tertentu).
type ChatLabel struct {
	ID      uint   `gorm:"primaryKey" json:"id"`
	AgentID uint   `gorm:"not null;uniqueIndex:idx_chatlabel,priority:1" json:"agent_id"`
	LabelID string `gorm:"size:64;not null;uniqueIndex:idx_chatlabel,priority:2" json:"label_id"`
	Sender  string `gorm:"size:32;not null;uniqueIndex:idx_chatlabel,priority:3" json:"sender"`
	// ChatJID = JID mentah persis seperti yang disimpan WhatsApp di index
	// app-state label_jid (bisa @lid). Pencabutan label wajib memakai bentuk
	// ini; kolom sender hanya nomor telepon untuk filter/tampilan.
	ChatJID string `gorm:"column:chat_jid;size:96" json:"chat_jid"`
}
