Files
gochat/backend/internal/model/inbox.go
T
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

53 lines
3.2 KiB
Go

package model
// Inbox represents a channel inbox that groups conversations.
// Reference: Chatwoot app/models/inbox.rb
//
// Chatwoot inbox attributes (permitted_params in InboxesController):
//
// name, avatar, greeting_enabled, greeting_message, enable_email_collect,
// csat_survey_enabled, enable_auto_assignment, working_hours_enabled,
// out_of_office_message, timezone, allow_messages_after_resolved,
// lock_to_single_conversation, portal_id, sender_name_type, business_name,
// csat_config (nested hash)
//
// Additional Chatwoot fields not in permitted_params but in model:
//
// channel_type, channel_id, account_id, email_address (for email channel),
// webhook_url (for API channel), identifier (unique slug)
type Inbox struct {
Base
AccountID uint `gorm:"index;not null" json:"account_id"`
Name string `gorm:"size:255;not null" json:"name"`
ChannelType string `gorm:"size:50;index;not null" json:"channel_type"` // web_widget, facebook, twitter, whatsapp, telegram, email, api, etc
ChannelID uint `gorm:"index;not null" json:"channel_id"`
EnableAutoAssignment bool `gorm:"default:false" json:"enable_auto_assignment"`
AutoAssignmentLimit int `gorm:"default:0" json:"auto_assignment_limit"`
Enabled bool `gorm:"default:true" json:"enabled"`
ChannelConfig string `gorm:"type:text" json:"-" secure:"channel_config"` // JSON-encoded per-inbox channel configuration
// Chatwoot inbox settings (from permitted_params)
GreetingEnabled bool `gorm:"default:false" json:"greeting_enabled"`
GreetingMessage string `gorm:"type:text" json:"greeting_message,omitempty"`
EnableEmailCollect bool `gorm:"default:true" json:"enable_email_collect"`
CsatSurveyEnabled bool `gorm:"default:false" json:"csat_survey_enabled"`
WorkingHoursEnabled bool `gorm:"default:false" json:"working_hours_enabled"`
OutOfOfficeMessage string `gorm:"type:text" json:"out_of_office_message,omitempty"`
Timezone string `gorm:"size:100" json:"timezone,omitempty"` // e.g. "Asia/Kolkata"
AllowMessagesAfterResolved bool `gorm:"default:true" json:"allow_messages_after_resolved"`
LockToSingleConversation bool `gorm:"default:false" json:"lock_to_single_conversation"`
SenderNameType string `gorm:"size:50;default:friendly" json:"sender_name_type,omitempty"` // friendly, professional
BusinessName string `gorm:"size:255" json:"business_name,omitempty"`
CsatConfig string `gorm:"type:text" json:"csat_config,omitempty"` // JSON-encoded CSAT survey configuration
AvatarURL string `gorm:"size:1024" json:"avatar_url,omitempty"` // URL to inbox avatar image
PortalID *uint `gorm:"index" json:"portal_id,omitempty"` // FK to help-center portal (nullable)
// API inbox specific fields
WebhookURL string `gorm:"size:1024" json:"webhook_url,omitempty"` // webhook URL for API inboxes
Secret string `gorm:"size:512" json:"-" secure:"webhook_secret"` // HMAC secret for API inbox webhook verification
WorkingHours []WorkingHour `gorm:"foreignKey:InboxID" json:"working_hours,omitempty"`
}
func (Inbox) TableName() string { return "inboxes" }