package channel

import (
	"time"

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

// ChannelTiktok represents a TikTok channel configuration.
// Reference: P2B M2 spec
type ChannelTiktok struct {
	ID            uint      `gorm:"primaryKey" json:"id"`
	InboxID       uint      `gorm:"uniqueIndex;not null" json:"inbox_id"`
	AccessToken   string    `gorm:"size:1024" json:"-"`
	RefreshToken  string    `gorm:"size:1024" json:"-"`
	ExpiresAt     *time.Time `json:"expires_at,omitempty"`
	TiktokAccountID string  `gorm:"size:255;not null;index" json:"tiktok_account_id"`
	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 (ChannelTiktok) TableName() string { return "channel_tiktoks" }
func (c ChannelTiktok) GetInboxID() uint                    { return c.InboxID }
func (c ChannelTiktok) GetChannelType() model.InboxChannelType { return model.InboxChannelTypeTiktok }