Files
Rogeeandrogee f719529d66 fix(security): harden auth and secret handling (HH-444) (#101)
* fix(security): harden auth and credential handling (HH-444)

* fix(security): address HH-444 review blockers

* fix(security): close remaining HH-444 review blockers

---------

Co-authored-by: Rogee <rogee@ipao.vip>
2026-08-22 15:45:06 +08:00

30 lines
1.4 KiB
Go

package channel
import (
"time"
"github.com/gochat/gochat/internal/model"
"gorm.io/datatypes"
)
// ChannelAPI represents a REST API channel configuration.
// Reference: Chatwoot Channel::Api + P2B M2 spec
type ChannelAPI struct {
ID uint `gorm:"primaryKey" json:"id"`
InboxID uint `gorm:"uniqueIndex;not null" json:"inbox_id"`
WebhookURL string `gorm:"size:512" json:"webhook_url"`
Secret string `gorm:"size:512" json:"-" secure:"webhook_secret"`
HMACToken string `gorm:"size:512" json:"-" secure:"hmac_token"`
HMACMandatory bool `gorm:"column:hmac_mandatory;default:false" json:"hmac_mandatory"`
AdditionalAttributes datatypes.JSON `gorm:"type:jsonb;default:'{}'" json:"additional_attributes"`
Identifier string `gorm:"size:255" json:"identifier"`
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 (ChannelAPI) TableName() string { return "channel_api" }
func (c ChannelAPI) GetInboxID() uint { return c.InboxID }
func (c ChannelAPI) GetChannelType() model.InboxChannelType { return model.InboxChannelTypeAPI }