package model

import (
	"time"
)

// ContactInbox represents the join between Contact and Inbox with source info.
// Reference: Chatwoot ContactInbox model + P2B M4 spec
type ContactInbox struct {
	ID               uint      `gorm:"primaryKey" json:"id"`
	ContactID        uint      `gorm:"not null;index" json:"contact_id"`
	InboxID          uint      `gorm:"not null;index" json:"inbox_id"`
	SourceID         string    `gorm:"size:255;index" json:"source_id"`
	HMACToken        string    `gorm:"size:255" json:"hmac_token"`
	PubsubToken      string    `gorm:"size:255" json:"pubsub_token"`
	CreatedAt        time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt        time.Time `gorm:"autoUpdateTime" json:"updated_at"`

	Contact Contact `gorm:"foreignKey:ContactID" json:"contact,omitempty"`
	Inbox   Inbox   `gorm:"foreignKey:InboxID" json:"inbox,omitempty"`
}

func (ContactInbox) TableName() string { return "contact_inboxes" }