models

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2026 License: AGPL-3.0, AGPL-3.0-or-later Imports: 10 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

SPDX-License-Identifier: AGPL-3.0-or-later

Index

Constants

View Source
const SecretMask = "********"

SecretMask is the value returned for masked secrets

Variables

View Source
var (
	ErrSignatureNotFound      = errors.New("signature not found")
	ErrSignatureAlreadyExists = errors.New("signature already exists")
	ErrInvalidUser            = errors.New("invalid user")
	ErrInvalidDocument        = errors.New("invalid document ID")
	ErrDatabaseConnection     = errors.New("database connection error")
	ErrUnauthorized           = errors.New("unauthorized")
	ErrDomainNotAllowed       = errors.New("domain not allowed")
	ErrDocumentModified       = errors.New("document has been modified since creation")
	ErrDocumentNotFound       = errors.New("document not found")
)

Functions

func IsSecretMasked

func IsSecretMasked(value string) bool

IsSecretMasked checks if a value is the secret mask

Types

type ChecksumVerification

type ChecksumVerification struct {
	ID                 int64     `json:"id" db:"id"`
	TenantID           uuid.UUID `json:"tenant_id" db:"tenant_id"`
	DocID              string    `json:"doc_id" db:"doc_id"`
	VerifiedBy         string    `json:"verified_by" db:"verified_by"`
	VerifiedAt         time.Time `json:"verified_at" db:"verified_at"`
	StoredChecksum     string    `json:"stored_checksum" db:"stored_checksum"`
	CalculatedChecksum string    `json:"calculated_checksum" db:"calculated_checksum"`
	Algorithm          string    `json:"algorithm" db:"algorithm"`
	IsValid            bool      `json:"is_valid" db:"is_valid"`
	ErrorMessage       *string   `json:"error_message,omitempty" db:"error_message"`
}

ChecksumVerification represents a verification attempt of a document's checksum

type ChecksumVerificationResult

type ChecksumVerificationResult struct {
	Valid              bool   `json:"valid"`
	StoredChecksum     string `json:"stored_checksum"`
	CalculatedChecksum string `json:"calculated_checksum"`
	Algorithm          string `json:"algorithm"`
	Message            string `json:"message"`
	HasReferenceHash   bool   `json:"has_reference_hash"`
}

ChecksumVerificationResult represents the result of a checksum verification operation

type ConfigCategory

type ConfigCategory string

ConfigCategory represents the category of configuration

const (
	ConfigCategoryGeneral   ConfigCategory = "general"
	ConfigCategoryOIDC      ConfigCategory = "oidc"
	ConfigCategoryMagicLink ConfigCategory = "magiclink"
	ConfigCategorySMTP      ConfigCategory = "smtp"
	ConfigCategoryStorage   ConfigCategory = "storage"
)

func AllConfigCategories

func AllConfigCategories() []ConfigCategory

AllConfigCategories returns all valid configuration categories

func (ConfigCategory) IsValid

func (c ConfigCategory) IsValid() bool

IsValid checks if the category is valid

type ConfigSecrets

type ConfigSecrets struct {
	OIDCClientSecret string `json:"oidc_client_secret,omitempty"`
	SMTPPassword     string `json:"smtp_password,omitempty"`
	S3SecretKey      string `json:"s3_secret_key,omitempty"`
}

ConfigSecrets holds all encrypted secrets

type ContactInfo

type ContactInfo struct {
	Name  string
	Email string
}

ContactInfo represents a contact with optional name and email

type DocCompletionStats

type DocCompletionStats struct {
	DocID          string  `json:"doc_id"`
	ExpectedCount  int     `json:"expected_count"`
	SignedCount    int     `json:"signed_count"`
	PendingCount   int     `json:"pending_count"`
	CompletionRate float64 `json:"completion_rate"` // Percentage 0-100
}

DocCompletionStats provides completion statistics for a document

type Document

type Document struct {
	DocID             string     `json:"doc_id" db:"doc_id"`
	TenantID          uuid.UUID  `json:"tenant_id" db:"tenant_id"`
	Title             string     `json:"title" db:"title"`
	URL               string     `json:"url" db:"url"`
	Checksum          string     `json:"checksum" db:"checksum"`
	ChecksumAlgorithm string     `json:"checksum_algorithm" db:"checksum_algorithm"`
	Description       string     `json:"description" db:"description"`
	ReadMode          string     `json:"read_mode" db:"read_mode"`
	AllowDownload     bool       `json:"allow_download" db:"allow_download"`
	RequireFullRead   bool       `json:"require_full_read" db:"require_full_read"`
	VerifyChecksum    bool       `json:"verify_checksum" db:"verify_checksum"`
	CreatedAt         time.Time  `json:"created_at" db:"created_at"`
	UpdatedAt         time.Time  `json:"updated_at" db:"updated_at"`
	CreatedBy         string     `json:"created_by" db:"created_by"`
	DeletedAt         *time.Time `json:"deleted_at,omitempty" db:"deleted_at"`

	// Storage fields for uploaded files
	StorageKey       string `json:"storage_key,omitempty" db:"storage_key"`
	StorageProvider  string `json:"storage_provider,omitempty" db:"storage_provider"`
	FileSize         int64  `json:"file_size,omitempty" db:"file_size"`
	MimeType         string `json:"mime_type,omitempty" db:"mime_type"`
	OriginalFilename string `json:"original_filename,omitempty" db:"original_filename"`
}

Document represents document metadata for tracking and integrity verification

func (*Document) GetDocID

func (d *Document) GetDocID() string

GetDocID returns the document ID

func (*Document) GetExpectedChecksumLength

func (d *Document) GetExpectedChecksumLength() int

GetExpectedChecksumLength returns the expected length for the configured algorithm

func (*Document) GetTitle

func (d *Document) GetTitle() string

GetTitle returns the document title

func (*Document) GetURL

func (d *Document) GetURL() string

GetURL returns the document URL

func (*Document) HasChecksum

func (d *Document) HasChecksum() bool

HasChecksum returns true if the document has a checksum configured

func (*Document) IsStored

func (d *Document) IsStored() bool

IsStored returns true if the document has an uploaded file

type DocumentInput

type DocumentInput struct {
	Title             string `json:"title"`
	URL               string `json:"url"`
	Checksum          string `json:"checksum"`
	ChecksumAlgorithm string `json:"checksum_algorithm"`
	Description       string `json:"description"`
	ReadMode          string `json:"read_mode"`
	AllowDownload     *bool  `json:"allow_download"`
	RequireFullRead   *bool  `json:"require_full_read"`
	VerifyChecksum    *bool  `json:"verify_checksum"`

	// Storage fields for uploaded files
	StorageKey       string `json:"storage_key,omitempty"`
	StorageProvider  string `json:"storage_provider,omitempty"`
	FileSize         int64  `json:"file_size,omitempty"`
	MimeType         string `json:"mime_type,omitempty"`
	OriginalFilename string `json:"original_filename,omitempty"`
}

DocumentInput represents the input for creating/updating document metadata

type EmailPeriodStats

type EmailPeriodStats struct {
	Sent   int `json:"sent"`
	Failed int `json:"failed"`
	Queued int `json:"queued"`
}

EmailPeriodStats represents email statistics for a time period

type EmailPriority

type EmailPriority int

EmailPriority represents email priority levels

const (
	EmailPriorityNormal EmailPriority = 0
	EmailPriorityHigh   EmailPriority = 10
	EmailPriorityUrgent EmailPriority = 100
)

type EmailQueueInput

type EmailQueueInput struct {
	ToAddresses   []string               `json:"to_addresses"`
	CcAddresses   []string               `json:"cc_addresses,omitempty"`
	BccAddresses  []string               `json:"bcc_addresses,omitempty"`
	Subject       string                 `json:"subject"`
	Template      string                 `json:"template"`
	Locale        string                 `json:"locale"`
	Data          map[string]interface{} `json:"data"`
	Headers       map[string]string      `json:"headers,omitempty"`
	Priority      EmailPriority          `json:"priority"`
	ScheduledFor  *time.Time             `json:"scheduled_for,omitempty"` // nil = immediate
	ReferenceType *string                `json:"reference_type,omitempty"`
	ReferenceID   *string                `json:"reference_id,omitempty"`
	CreatedBy     *string                `json:"created_by,omitempty"`
	MaxRetries    int                    `json:"max_retries"` // 0 = use default (3)
}

EmailQueueInput represents the input for creating a new email queue item

type EmailQueueItem

type EmailQueueItem struct {
	ID            int64            `json:"id"`
	TenantID      uuid.UUID        `json:"tenant_id" db:"tenant_id"`
	ToAddresses   []string         `json:"to_addresses"`
	CcAddresses   []string         `json:"cc_addresses,omitempty"`
	BccAddresses  []string         `json:"bcc_addresses,omitempty"`
	Subject       string           `json:"subject"`
	Template      string           `json:"template"`
	Locale        string           `json:"locale"`
	Data          json.RawMessage  `json:"data"`
	Headers       NullRawMessage   `json:"headers,omitempty"`
	Status        EmailQueueStatus `json:"status"`
	Priority      EmailPriority    `json:"priority"`
	RetryCount    int              `json:"retry_count"`
	MaxRetries    int              `json:"max_retries"`
	CreatedAt     time.Time        `json:"created_at"`
	ScheduledFor  time.Time        `json:"scheduled_for"`
	ProcessedAt   *time.Time       `json:"processed_at,omitempty"`
	NextRetryAt   *time.Time       `json:"next_retry_at,omitempty"`
	LastError     *string          `json:"last_error,omitempty"`
	ErrorDetails  NullRawMessage   `json:"error_details,omitempty"`
	ReferenceType *string          `json:"reference_type,omitempty"`
	ReferenceID   *string          `json:"reference_id,omitempty"`
	CreatedBy     *string          `json:"created_by,omitempty"`
}

EmailQueueItem represents an email in the processing queue

type EmailQueueStats

type EmailQueueStats struct {
	TotalPending    int              `json:"total_pending"`
	TotalProcessing int              `json:"total_processing"`
	TotalSent       int              `json:"total_sent"`
	TotalFailed     int              `json:"total_failed"`
	OldestPending   *time.Time       `json:"oldest_pending,omitempty"`
	AverageRetries  float64          `json:"average_retries"`
	ByStatus        map[string]int   `json:"by_status"`
	ByPriority      map[string]int   `json:"by_priority"`
	Last24Hours     EmailPeriodStats `json:"last_24_hours"`
}

EmailQueueStats represents aggregated statistics for the email queue

type EmailQueueStatus

type EmailQueueStatus string

EmailQueueStatus represents the status of an email in the queue

const (
	EmailStatusPending    EmailQueueStatus = "pending"
	EmailStatusProcessing EmailQueueStatus = "processing"
	EmailStatusSent       EmailQueueStatus = "sent"
	EmailStatusFailed     EmailQueueStatus = "failed"
	EmailStatusCancelled  EmailQueueStatus = "cancelled"
)

type ExpectedSigner

type ExpectedSigner struct {
	ID       int64     `json:"id" db:"id"`
	TenantID uuid.UUID `json:"tenant_id" db:"tenant_id"`
	DocID    string    `json:"doc_id" db:"doc_id"`
	Email    string    `json:"email" db:"email"`
	Name     string    `json:"name" db:"name"`
	AddedAt  time.Time `json:"added_at" db:"added_at"`
	AddedBy  string    `json:"added_by" db:"added_by"`
	Notes    *string   `json:"notes,omitempty" db:"notes"`
}

ExpectedSigner represents an expected signer for a document

type ExpectedSignerWithStatus

type ExpectedSignerWithStatus struct {
	ExpectedSigner
	HasSigned             bool       `json:"has_signed"`
	SignedAt              *time.Time `json:"signed_at,omitempty"`
	UserName              *string    `json:"user_name,omitempty"`
	LastReminderSent      *time.Time `json:"last_reminder_sent,omitempty"`
	ReminderCount         int        `json:"reminder_count"`
	DaysSinceAdded        int        `json:"days_since_added"`
	DaysSinceLastReminder *int       `json:"days_since_last_reminder,omitempty"`
}

ExpectedSignerWithStatus combines expected signer info with signature status

type GeneralConfig

type GeneralConfig struct {
	Organisation       string `json:"organisation"`
	OnlyAdminCanCreate bool   `json:"only_admin_can_create"`
}

GeneralConfig holds general application settings

type JSONB

type JSONB map[string]interface{}

JSONB is a helper type for handling JSONB columns

func (*JSONB) Scan

func (j *JSONB) Scan(value interface{}) error

Scan implements sql.Scanner

func (JSONB) Value

func (j JSONB) Value() (driver.Value, error)

Value implements driver.Valuer

type MagicLinkAuthAttempt

type MagicLinkAuthAttempt struct {
	ID            int64      `json:"id" db:"id"`
	TenantID      *uuid.UUID `json:"tenant_id,omitempty" db:"tenant_id"` // May be NULL before authentication
	Email         string     `json:"email" db:"email"`
	Success       bool       `json:"success" db:"success"`
	FailureReason string     `json:"failure_reason,omitempty" db:"failure_reason"`
	IPAddress     string     `json:"ip_address" db:"ip_address"`
	UserAgent     string     `json:"user_agent,omitempty" db:"user_agent"`
	AttemptedAt   time.Time  `json:"attempted_at" db:"attempted_at"`
}

MagicLinkAuthAttempt représente une tentative d'authentification

type MagicLinkConfig

type MagicLinkConfig struct {
	Enabled bool `json:"enabled"`
}

MagicLinkConfig holds MagicLink authentication settings

type MagicLinkToken

type MagicLinkToken struct {
	ID                 int64      `json:"id" db:"id"`
	TenantID           *uuid.UUID `json:"tenant_id,omitempty" db:"tenant_id"` // NULL for login requests, set for admin reminders
	Token              string     `json:"token" db:"token"`
	Email              string     `json:"email" db:"email"`
	CreatedAt          time.Time  `json:"created_at" db:"created_at"`
	ExpiresAt          time.Time  `json:"expires_at" db:"expires_at"`
	UsedAt             *time.Time `json:"used_at,omitempty" db:"used_at"`
	UsedByIP           *string    `json:"used_by_ip,omitempty" db:"used_by_ip"`
	UsedByUserAgent    *string    `json:"used_by_user_agent,omitempty" db:"used_by_user_agent"`
	RedirectTo         string     `json:"redirect_to" db:"redirect_to"` // URL destination après auth (ex: /?doc=xxx)
	CreatedByIP        string     `json:"created_by_ip" db:"created_by_ip"`
	CreatedByUserAgent string     `json:"created_by_user_agent" db:"created_by_user_agent"`
	Purpose            string     `json:"purpose" db:"purpose"`         // 'login' or 'reminder_auth'
	DocID              *string    `json:"doc_id,omitempty" db:"doc_id"` // Document ID for reminder_auth (NULL for login)
}

MagicLinkToken représente un token de connexion Magic Link

func (*MagicLinkToken) IsValid

func (t *MagicLinkToken) IsValid() bool

IsValid vérifie si le token est valide (non expiré, non utilisé)

type MutableConfig

type MutableConfig struct {
	General   GeneralConfig   `json:"general"`
	OIDC      OIDCConfig      `json:"oidc"`
	MagicLink MagicLinkConfig `json:"magiclink"`
	SMTP      SMTPConfig      `json:"smtp"`
	Storage   StorageConfig   `json:"storage"`
	UpdatedAt time.Time       `json:"updated_at"`
}

MutableConfig combines all mutable configuration sections

func (*MutableConfig) HasAtLeastOneAuthMethod

func (c *MutableConfig) HasAtLeastOneAuthMethod() bool

HasAtLeastOneAuthMethod validates that at least one auth method is enabled

func (*MutableConfig) MagicLinkRequiresSMTP

func (c *MutableConfig) MagicLinkRequiresSMTP() bool

MagicLinkRequiresSMTP validates that MagicLink has SMTP configured

func (*MutableConfig) MaskSecrets

func (c *MutableConfig) MaskSecrets() *MutableConfig

MaskSecrets returns a copy of MutableConfig with secrets masked

type NullRawMessage

type NullRawMessage struct {
	RawMessage json.RawMessage
	Valid      bool
}

NullRawMessage is a nullable json.RawMessage for database scanning

func (*NullRawMessage) Scan

func (n *NullRawMessage) Scan(value interface{}) error

Scan implements sql.Scanner

func (NullRawMessage) Value

func (n NullRawMessage) Value() (driver.Value, error)

Value implements driver.Valuer

type OAuthSession

type OAuthSession struct {
	ID                    int64
	TenantID              uuid.UUID
	SessionID             string
	UserSub               string
	RefreshTokenEncrypted []byte
	AccessTokenExpiresAt  time.Time
	CreatedAt             time.Time
	UpdatedAt             time.Time
	LastRefreshedAt       *time.Time
	UserAgent             string
	IPAddress             string
}

OAuthSession represents an OAuth session with encrypted refresh token

type OIDCConfig

type OIDCConfig struct {
	Enabled       bool     `json:"enabled"`
	Provider      string   `json:"provider"` // google, github, gitlab, custom
	ClientID      string   `json:"client_id"`
	ClientSecret  string   `json:"client_secret,omitempty"`
	AuthURL       string   `json:"auth_url,omitempty"`
	TokenURL      string   `json:"token_url,omitempty"`
	UserInfoURL   string   `json:"userinfo_url,omitempty"`
	LogoutURL     string   `json:"logout_url,omitempty"`
	Scopes        []string `json:"scopes,omitempty"`
	AllowedDomain string   `json:"allowed_domain,omitempty"`
	AutoLogin     bool     `json:"auto_login"`
}

OIDCConfig holds OIDC/OAuth2 authentication settings

type OIDCSecrets

type OIDCSecrets struct {
	ClientSecret string `json:"client_secret,omitempty"`
}

OIDCSecrets holds the secret fields for OIDC config

type ReminderLog

type ReminderLog struct {
	ID             int64     `json:"id" db:"id"`
	TenantID       uuid.UUID `json:"tenant_id" db:"tenant_id"`
	DocID          string    `json:"doc_id" db:"doc_id"`
	RecipientEmail string    `json:"recipient_email" db:"recipient_email"`
	SentAt         time.Time `json:"sent_at" db:"sent_at"`
	SentBy         string    `json:"sent_by" db:"sent_by"`
	TemplateUsed   string    `json:"template_used" db:"template_used"`
	Status         string    `json:"status" db:"status"`
	ErrorMessage   *string   `json:"error_message,omitempty" db:"error_message"`
}

ReminderLog represents a log entry for an email reminder sent to a signer

type ReminderSendResult

type ReminderSendResult struct {
	TotalAttempted   int      `json:"total_attempted"`
	SuccessfullySent int      `json:"successfully_sent"`
	Failed           int      `json:"failed"`
	Errors           []string `json:"errors,omitempty"`
}

ReminderSendResult represents the result of a bulk reminder send operation

type ReminderStats

type ReminderStats struct {
	TotalSent    int        `json:"total_sent"`
	LastSentAt   *time.Time `json:"last_sent_at,omitempty"`
	PendingCount int        `json:"pending_count"`
}

ReminderStats provides statistics about reminders for a document

type SMTPConfig

type SMTPConfig struct {
	Host               string `json:"host"`
	Port               int    `json:"port"`
	Username           string `json:"username"`
	Password           string `json:"password,omitempty"`
	TLS                bool   `json:"tls"`
	StartTLS           bool   `json:"starttls"`
	InsecureSkipVerify bool   `json:"insecure_skip_verify"`
	Timeout            string `json:"timeout"`
	From               string `json:"from"`
	FromName           string `json:"from_name"`
	SubjectPrefix      string `json:"subject_prefix,omitempty"`
}

SMTPConfig holds SMTP email settings

func (*SMTPConfig) IsConfigured

func (c *SMTPConfig) IsConfigured() bool

IsConfigured returns true if SMTP is properly configured

type SMTPSecrets

type SMTPSecrets struct {
	Password string `json:"password,omitempty"`
}

SMTPSecrets holds the secret fields for SMTP config

type Signature

type Signature struct {
	ID           int64      `json:"id" db:"id"`
	TenantID     uuid.UUID  `json:"tenant_id" db:"tenant_id"`
	DocID        string     `json:"doc_id" db:"doc_id"`
	UserSub      string     `json:"user_sub" db:"user_sub"`
	UserEmail    string     `json:"user_email" db:"user_email"`
	UserName     string     `json:"user_name,omitempty" db:"user_name"`
	SignedAtUTC  time.Time  `json:"signed_at" db:"signed_at"`
	DocChecksum  string     `json:"doc_checksum,omitempty" db:"doc_checksum"`
	PayloadHash  string     `json:"payload_hash" db:"payload_hash"`
	Signature    string     `json:"signature" db:"signature"`
	Nonce        string     `json:"nonce" db:"nonce"`
	Referer      *string    `json:"referer,omitempty" db:"referer"`
	PrevHash     *string    `json:"prev_hash,omitempty" db:"prev_hash"`
	CreatedAt    time.Time  `json:"created_at" db:"created_at"`
	HashVersion  int        `json:"hash_version" db:"hash_version"`
	DocDeletedAt *time.Time `json:"doc_deleted_at,omitempty" db:"doc_deleted_at"`
	// Document metadata enriched from LEFT JOIN (not stored in signatures table)
	DocTitle string `json:"doc_title,omitempty"`
	DocURL   string `json:"doc_url,omitempty"`
}

func (*Signature) ComputeRecordHash

func (s *Signature) ComputeRecordHash() string

ComputeRecordHash computes the hash of the signature record for blockchain integrity Uses versioned hash algorithms for backward compatibility

func (*Signature) GetServiceInfo

func (s *Signature) GetServiceInfo() *services.ServiceInfo

type SignatureRequest

type SignatureRequest struct {
	DocID   string
	User    *User
	Referer *string
}

type SignatureStatus

type SignatureStatus struct {
	DocID     string
	UserEmail string
	IsSigned  bool
	SignedAt  *time.Time
}

type StorageConfig

type StorageConfig struct {
	Type        string `json:"type"` // "", "local", "s3"
	MaxSizeMB   int64  `json:"max_size_mb"`
	LocalPath   string `json:"local_path,omitempty"`
	S3Endpoint  string `json:"s3_endpoint,omitempty"`
	S3Bucket    string `json:"s3_bucket,omitempty"`
	S3AccessKey string `json:"s3_access_key,omitempty"`
	S3SecretKey string `json:"s3_secret_key,omitempty"`
	S3Region    string `json:"s3_region,omitempty"`
	S3UseSSL    bool   `json:"s3_use_ssl"`
}

StorageConfig holds document storage settings

func (*StorageConfig) IsEnabled

func (c *StorageConfig) IsEnabled() bool

IsEnabled returns true if storage is enabled

type StorageSecrets

type StorageSecrets struct {
	S3SecretKey string `json:"s3_secret_key,omitempty"`
}

StorageSecrets holds the secret fields for Storage config

type TenantConfig

type TenantConfig struct {
	ID               int64           `json:"id" db:"id"`
	TenantID         uuid.UUID       `json:"tenant_id" db:"tenant_id"`
	Category         ConfigCategory  `json:"category" db:"category"`
	Config           json.RawMessage `json:"config" db:"config"`
	SecretsEncrypted []byte          `json:"-" db:"secrets_encrypted"`
	Version          int             `json:"version" db:"version"`
	CreatedAt        time.Time       `json:"created_at" db:"created_at"`
	UpdatedAt        time.Time       `json:"updated_at" db:"updated_at"`
	UpdatedBy        *string         `json:"updated_by,omitempty" db:"updated_by"`
}

TenantConfig represents a configuration section stored in the database

type TenantID

type TenantID = uuid.UUID

TenantID is an alias for uuid.UUID representing a tenant identifier.

type User

type User = types.User

User is an alias for the unified user type. This allows domain code to use models.User while sharing the same underlying type.

type Webhook

type Webhook struct {
	ID              int64             `json:"id"`
	TenantID        uuid.UUID         `json:"tenant_id" db:"tenant_id"`
	Title           string            `json:"title"`
	TargetURL       string            `json:"targetUrl"`
	Secret          string            `json:"-"`
	Active          bool              `json:"active"`
	Events          []string          `json:"events"`
	Headers         map[string]string `json:"headers,omitempty"`
	Description     string            `json:"description,omitempty"`
	CreatedBy       string            `json:"createdBy,omitempty"`
	CreatedAt       time.Time         `json:"createdAt"`
	UpdatedAt       time.Time         `json:"updatedAt"`
	LastDeliveredAt *time.Time        `json:"lastDeliveredAt,omitempty"`
	FailureCount    int               `json:"failureCount"`
}

type WebhookDelivery

type WebhookDelivery struct {
	ID              int64                 `json:"id"`
	TenantID        uuid.UUID             `json:"tenant_id" db:"tenant_id"`
	WebhookID       int64                 `json:"webhookId"`
	EventType       string                `json:"eventType"`
	EventID         string                `json:"eventId"`
	Payload         json.RawMessage       `json:"payload"`
	Status          WebhookDeliveryStatus `json:"status"`
	RetryCount      int                   `json:"retryCount"`
	MaxRetries      int                   `json:"maxRetries"`
	Priority        int                   `json:"priority"`
	CreatedAt       time.Time             `json:"createdAt"`
	ScheduledFor    time.Time             `json:"scheduledFor"`
	ProcessedAt     *time.Time            `json:"processedAt,omitempty"`
	NextRetryAt     *time.Time            `json:"nextRetryAt,omitempty"`
	RequestHeaders  NullRawMessage        `json:"requestHeaders,omitempty"`
	ResponseStatus  *int                  `json:"responseStatus,omitempty"`
	ResponseHeaders NullRawMessage        `json:"responseHeaders,omitempty"`
	ResponseBody    *string               `json:"responseBody,omitempty"`
	LastError       *string               `json:"lastError,omitempty"`
}

type WebhookDeliveryInput

type WebhookDeliveryInput struct {
	WebhookID    int64
	EventType    string
	EventID      string
	Payload      map[string]interface{}
	Priority     int
	MaxRetries   int
	ScheduledFor *time.Time
}

type WebhookDeliveryStatus

type WebhookDeliveryStatus string
const (
	WebhookStatusPending    WebhookDeliveryStatus = "pending"
	WebhookStatusProcessing WebhookDeliveryStatus = "processing"
	WebhookStatusDelivered  WebhookDeliveryStatus = "delivered"
	WebhookStatusFailed     WebhookDeliveryStatus = "failed"
	WebhookStatusCancelled  WebhookDeliveryStatus = "cancelled"
)

type WebhookInput

type WebhookInput struct {
	Title       string            `json:"title"`
	TargetURL   string            `json:"targetUrl"`
	Secret      string            `json:"secret"`
	Active      bool              `json:"active"`
	Events      []string          `json:"events"`
	Headers     map[string]string `json:"headers,omitempty"`
	Description string            `json:"description,omitempty"`
	CreatedBy   string            `json:"createdBy,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL