All checks were successful
check / check (push) Successful in 2m2s
Add a new 'slack' target type that sends webhook events as formatted messages to any Slack-compatible incoming webhook URL (Slack, Mattermost, and other compatible services). Messages include event metadata (method, content type, timestamp, body size) and the payload pretty-printed in a code block. JSON payloads are automatically formatted with indentation; non-JSON payloads are shown as raw text. Large payloads are truncated at 3500 chars. Changes: - Add TargetTypeSlack constant to model_target.go - Add SlackTargetConfig struct and deliverSlack method to delivery engine - Add FormatSlackMessage (exported) for building Slack message text - Route slack targets in processDelivery switch - Handle slack type in HandleTargetCreate with webhook_url config - Add slack option to source_detail.html target creation form - Add comprehensive tests (config parsing, message formatting, delivery success/failure, routing) - Update README with slack target documentation
33 lines
1.0 KiB
Go
33 lines
1.0 KiB
Go
package database
|
|
|
|
// TargetType represents the type of delivery target
|
|
type TargetType string
|
|
|
|
const (
|
|
TargetTypeHTTP TargetType = "http"
|
|
TargetTypeDatabase TargetType = "database"
|
|
TargetTypeLog TargetType = "log"
|
|
TargetTypeSlack TargetType = "slack"
|
|
)
|
|
|
|
// Target represents a delivery target for a webhook
|
|
type Target struct {
|
|
BaseModel
|
|
|
|
WebhookID string `gorm:"type:uuid;not null" json:"webhook_id"`
|
|
Name string `gorm:"not null" json:"name"`
|
|
Type TargetType `gorm:"not null" json:"type"`
|
|
Active bool `gorm:"default:true" json:"active"`
|
|
|
|
// Configuration fields (JSON stored based on type)
|
|
Config string `gorm:"type:text" json:"config"` // JSON configuration
|
|
|
|
// For HTTP targets (max_retries=0 means fire-and-forget, >0 enables retries with backoff)
|
|
MaxRetries int `json:"max_retries,omitempty"`
|
|
MaxQueueSize int `json:"max_queue_size,omitempty"`
|
|
|
|
// Relations
|
|
Webhook Webhook `json:"webhook,omitempty"`
|
|
Deliveries []Delivery `json:"deliveries,omitempty"`
|
|
}
|