package channel

import (
	"time"

	"github.com/gochat/gochat/internal/model"
)

// ChannelInstagram represents an Instagram DM channel configuration.
// Reference: Chatwoot Channel::Instagram + P2B M2 spec
type ChannelInstagram struct {
	ID               uint      `gorm:"primaryKey" json:"id"`
	InboxID          uint      `gorm:"uniqueIndex;not null" json:"inbox_id"`
	IGAccountID      string    `gorm:"size:255;not null;index" json:"ig_account_id"`
	AccessToken      string    `gorm:"size:1024;not null" json:"-"`
	IGHandle         string    `gorm:"size:255" json:"ig_handle"`
	ReauthRequired   bool      `gorm:"default:false" json:"reauth_required"`
	CreatedAt        time.Time `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt        time.Time `gorm:"autoUpdateTime" json:"updated_at"`

	Inbox model.Inbox `gorm:"foreignKey:InboxID" json:"inbox,omitempty"`
}

func (ChannelInstagram) TableName() string { return "channel_instagrams" }
func (c ChannelInstagram) GetInboxID() uint                    { return c.InboxID }
func (c ChannelInstagram) GetChannelType() model.InboxChannelType { return model.InboxChannelTypeInstagram }