mirror of
				https://github.com/abhinavxd/libredesk.git
				synced 2025-11-04 05:53:30 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			48 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			48 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package models
 | 
						|
 | 
						|
import (
 | 
						|
	"encoding/json"
 | 
						|
	"time"
 | 
						|
 | 
						|
	"github.com/lib/pq"
 | 
						|
)
 | 
						|
 | 
						|
// Webhook represents a webhook configuration
 | 
						|
type Webhook struct {
 | 
						|
	ID        int             `db:"id" json:"id"`
 | 
						|
	CreatedAt time.Time       `db:"created_at" json:"created_at"`
 | 
						|
	UpdatedAt time.Time       `db:"updated_at" json:"updated_at"`
 | 
						|
	Name      string          `db:"name" json:"name"`
 | 
						|
	URL       string          `db:"url" json:"url"`
 | 
						|
	Events    pq.StringArray  `db:"events" json:"events"`
 | 
						|
	Secret    string          `db:"secret" json:"secret,omitempty"`
 | 
						|
	IsActive  bool            `db:"is_active" json:"is_active"`
 | 
						|
	Headers   json.RawMessage `db:"headers" json:"headers"`
 | 
						|
}
 | 
						|
 | 
						|
// WebhookEvent represents an event that can trigger a webhook
 | 
						|
type WebhookEvent string
 | 
						|
 | 
						|
const (
 | 
						|
	// Conversation events
 | 
						|
	EventConversationCreated       WebhookEvent = "conversation.created"
 | 
						|
	EventConversationStatusChanged WebhookEvent = "conversation.status_changed"
 | 
						|
	EventConversationTagsChanged   WebhookEvent = "conversation.tags_changed"
 | 
						|
	EventConversationAssigned      WebhookEvent = "conversation.assigned"
 | 
						|
	EventConversationUnassigned    WebhookEvent = "conversation.unassigned"
 | 
						|
 | 
						|
	// Message events
 | 
						|
	EventMessageCreated WebhookEvent = "message.created"
 | 
						|
	EventMessageUpdated WebhookEvent = "message.updated"
 | 
						|
 | 
						|
	// Test event
 | 
						|
	EventWebhookTest WebhookEvent = "webhook.test"
 | 
						|
)
 | 
						|
 | 
						|
// WebhookPayload represents the payload sent to a webhook
 | 
						|
type WebhookPayload struct {
 | 
						|
	Event     WebhookEvent    `json:"event"`
 | 
						|
	Timestamp time.Time       `json:"timestamp"`
 | 
						|
	Data      json.RawMessage `json:",inline"`
 | 
						|
}
 |