webhooks

package
v1.11.2 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"webhooks",
	fx.Decorate(func(log *zap.Logger) *zap.Logger {
		return log.Named("webhooks")
	}),
	fx.Provide(NewRepository, fx.Private),
	fx.Provide(
		NewService,
	),
)

Functions

func Migrate

func Migrate(db *gorm.DB) error

Types

type Repository

type Repository struct {
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(db *gorm.DB) *Repository

func (*Repository) Delete

func (r *Repository) Delete(filters ...SelectFilter) error

func (*Repository) Replace

func (r *Repository) Replace(webhook *Webhook) error

func (*Repository) Select

func (r *Repository) Select(filters ...SelectFilter) ([]*Webhook, error)

type SelectFilter

type SelectFilter func(*selectFilter)

func WithExtID

func WithExtID(extID string) SelectFilter

func WithUserID

func WithUserID(userID string) SelectFilter

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(params ServiceParams) *Service

func (*Service) Delete

func (s *Service) Delete(userID string, filters ...SelectFilter) error

func (*Service) Replace

func (s *Service) Replace(userID string, webhook *smsgateway.Webhook) error

func (*Service) Select

func (s *Service) Select(userID string, filters ...SelectFilter) ([]smsgateway.Webhook, error)

type ServiceParams

type ServiceParams struct {
	fx.In

	IDGen db.IDGen

	Webhooks *Repository

	DevicesSvc *devices.Service
	PushSvc    *push.Service

	Logger *zap.Logger
}

type Webhook

type Webhook struct {
	ID     uint64 `json:"-"    gorm:"->;primaryKey;type:BIGINT UNSIGNED;autoIncrement"`
	ExtID  string `json:"id"   gorm:"not null;type:varchar(36);uniqueIndex:unq_webhooks_user_extid,priority:2"`
	UserID string `json:"-"    gorm:"<-:create;not null;type:varchar(32);uniqueIndex:unq_webhooks_user_extid,priority:1"`

	URL   string                  `json:"url"   validate:"required,http_url"   gorm:"not null;type:varchar(256)"`
	Event smsgateway.WebhookEvent `json:"event" gorm:"not null;type:varchar(32)"`

	User models.User `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"`

	models.TimedModel
}

Jump to

Keyboard shortcuts

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