package channel import "github.com/gochat/gochat/internal/model" // ChannelFacebook represents a Facebook Messenger channel. // Reference: Chatwoot app/models/channel/facebook_page.rb // // Chatwoot's ChannelFacebook (Channel::FacebookPage) model attributes: // - account_id: FK to Account // - page_id: Facebook Page ID // - page_access_token: Long-lived Page access token // - page_name: Display name of the FB Page // - reauthorization_required: Flag when token expires // // gochat enhancements beyond Chatwoot: // - instagram_business_account_id: Optional link to IG account for cross-channel // - app_id: FB App ID for webhook verification // - webhook_verify_token: Token for FB webhook subscription verification type ChannelFacebook struct { model.Base // Account foreign key AccountID uint `gorm:"index;not null" json:"account_id"` // Inbox foreign key — links to the Inbox that wraps this channel InboxID uint `gorm:"not null;uniqueIndex" json:"inbox_id"` // Facebook Page ID — identifies the FB Page for Messenger PageID string `gorm:"size:255;not null" json:"page_id"` // Long-lived Page access token for Graph API calls // Requires pages_messaging permission for Messenger PageAccessToken string `gorm:"size:512;not null" json:"page_access_token"` // Display name of the Facebook Page PageName string `gorm:"size:255" json:"page_name,omitempty"` // FB App ID — used for webhook verification and API calls AppID string `gorm:"size:255" json:"app_id,omitempty"` // Webhook verify token — used during FB webhook subscription // Reference: Chatwoot doesn't store this; GoChat adds for verification WebhookVerifyToken string `gorm:"size:255" json:"webhook_verify_token,omitempty"` // Instagram Business Account ID — links to IG account for cross-channel // When set, this FB Page also manages Instagram DMs // Reference: FB Graph API /me?fields=instagram_business_account InstagramBusinessAccountID string `gorm:"size:255" json:"instagram_business_account_id,omitempty"` // Tracks when the Page token needs reauthorization ReauthorizationRequired bool `gorm:"default:false" json:"reauthorization_required"` } func (ChannelFacebook) TableName() string { return "channel_facebook_pages" } // GetChannelBase returns the base channel fields for polymorphic access. func (c *ChannelFacebook) GetChannelBase() ChannelBase { return ChannelBase{ AccountID: c.AccountID, InboxID: c.InboxID, ChannelType: "facebook", } } // GetChannelType returns the channel type identifier. func (c *ChannelFacebook) GetChannelType() string { return "facebook" }