package channel

import (
	"time"

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

// ChannelFacebookPage represents a Facebook Messenger channel configuration.
// Reference: Chatwoot Channel::FacebookPage + P2B M2 spec
type ChannelFacebookPage struct {
	ID                uint      `gorm:"primaryKey" json:"id"`
	InboxID           uint      `gorm:"uniqueIndex;not null" json:"inbox_id"`
	PageID            string    `gorm:"size:255;not null;index" json:"page_id"`
	UserAccessToken   string    `gorm:"size:1024;not null" json:"-"`
	AppID             string    `gorm:"size:255" json:"app_id"`
	PageAccessToken   string    `gorm:"size:1024;not null" json:"-"`
	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 (ChannelFacebookPage) TableName() string { return "channel_facebook_pages" }
func (c ChannelFacebookPage) GetInboxID() uint                    { return c.InboxID }
func (c ChannelFacebookPage) GetChannelType() model.InboxChannelType { return model.InboxChannelTypeFacebookPage }