59 lines
1.9 KiB
Go
59 lines
1.9 KiB
Go
package channel
|
|
|
|
import "github.com/gochat/gochat/internal/model"
|
|
|
|
// ChannelGoogle represents a Google (Google Chat/Gmail) channel.
|
|
// Reference: Chatwoot does not have a native Google Chat channel — this is a gochat addition.
|
|
//
|
|
// Google integration uses Google OAuth 2.0 for authentication
|
|
// and Google Chat API / Gmail API for messaging.
|
|
//
|
|
// Features:
|
|
// - Google OAuth 2.0 authorization flow
|
|
// - Google Chat space messaging via Chat API
|
|
// - Gmail integration potential (like email channel)
|
|
// - Google webhook subscriptions for real-time events
|
|
type ChannelGoogle 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"`
|
|
|
|
// Google user email or unique identifier
|
|
GoogleUserID string `gorm:"size:255;not null;uniqueIndex" json:"google_user_id"`
|
|
|
|
// Google OAuth 2.0 access token
|
|
AccessToken string `gorm:"size:2048;not null" json:"-"`
|
|
|
|
// OAuth 2.0 refresh token for token renewal
|
|
RefreshToken string `gorm:"size:2048" json:"-"`
|
|
|
|
// Google Chat space ID (optional — for Google Chat integration)
|
|
SpaceID string `gorm:"size:255" json:"space_id,omitempty"`
|
|
|
|
// Display name of the connected Google resource
|
|
DisplayName string `gorm:"size:255" json:"display_name,omitempty"`
|
|
|
|
// Webhook subscription ID for Google Chat events
|
|
SubscriptionID string `gorm:"size:255" json:"subscription_id,omitempty"`
|
|
|
|
// Flag indicating reauthorization is required
|
|
ReauthorizationRequired bool `gorm:"default:false" json:"reauthorization_required,omitempty"`
|
|
}
|
|
|
|
func (ChannelGoogle) TableName() string { return "channel_google" }
|
|
|
|
func (c ChannelGoogle) GetChannelBase() ChannelBase {
|
|
return ChannelBase{
|
|
ID: c.ID,
|
|
AccountID: c.AccountID,
|
|
InboxID: c.InboxID,
|
|
ChannelType: "google",
|
|
}
|
|
}
|
|
|
|
func (c ChannelGoogle) GetChannelType() string { return "google" }
|