feat(automation): align attachment uploads

This commit is contained in:
2026-06-07 10:44:45 +08:00
parent f46bce7528
commit f7515b111d
6 changed files with 319 additions and 30 deletions
+20 -9
View File
@@ -84,19 +84,30 @@ func (a *Actions) Scan(value interface{}) error {
// Reference: Chatwoot AutomationRule — account_id, event_name, conditions, actions, active, name, description
type AutomationRule struct {
model.Base
AccountID uint `gorm:"index;not null" json:"account_id"`
EventName string `gorm:"size:100;index;not null" json:"event_name"` // e.g. "conversation_created", "message_created"
Name string `gorm:"size:255;not null" json:"name"`
Description string `gorm:"type:text" json:"description,omitempty"`
Conditions Conditions `gorm:"type:jsonb;default:'[]'" json:"conditions"`
Actions Actions `gorm:"type:jsonb;default:'[]'" json:"actions"`
Active bool `gorm:"not null" json:"active"`
ActiveAt *time.Time `gorm:"index" json:"active_at,omitempty"`
InactiveAt *time.Time `gorm:"index" json:"inactive_at,omitempty"`
AccountID uint `gorm:"index;not null" json:"account_id"`
EventName string `gorm:"size:100;index;not null" json:"event_name"` // e.g. "conversation_created", "message_created"
Name string `gorm:"size:255;not null" json:"name"`
Description string `gorm:"type:text" json:"description,omitempty"`
Conditions Conditions `gorm:"type:jsonb;default:'[]'" json:"conditions"`
Actions Actions `gorm:"type:jsonb;default:'[]'" json:"actions"`
Active bool `gorm:"not null" json:"active"`
ActiveAt *time.Time `gorm:"index" json:"active_at,omitempty"`
InactiveAt *time.Time `gorm:"index" json:"inactive_at,omitempty"`
Files []AutomationRuleFile `gorm:"-" json:"files,omitempty"`
}
func (AutomationRule) TableName() string { return "automation_rules" }
type AutomationRuleFile struct {
ID uint `json:"id"`
AutomationRuleID uint `json:"automation_rule_id"`
FileType string `json:"file_type"`
AccountID uint `json:"account_id"`
FileURL string `json:"file_url"`
BlobID uint `json:"blob_id"`
Filename string `json:"filename"`
}
// ===========================
// Macro model
// ===========================