notification.go 888 B

123456789101112131415161718192021
  1. package model
  2. import (
  3. "time"
  4. "gorm.io/datatypes"
  5. )
  6. // NotificationConfig stores notification channel configurations.
  7. type NotificationConfig struct {
  8. ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
  9. Name string `gorm:"size:100;not null" json:"name"`
  10. EventType string `gorm:"size:50;not null;index" json:"event_type"` // task_completed/task_failed/new_hot_merchant/schedule_run
  11. Channel string `gorm:"size:20;not null" json:"channel"` // webhook/tg_bot
  12. Config datatypes.JSON `gorm:"type:json" json:"config"` // {url: "..."} or {bot_token: "...", chat_id: "..."}
  13. Enabled bool `gorm:"default:true" json:"enabled"`
  14. CreatedAt time.Time `json:"created_at"`
  15. UpdatedAt time.Time `json:"updated_at"`
  16. }
  17. func (NotificationConfig) TableName() string { return "notification_configs" }