tasks

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Emit = delay.Func("webhook-emit", func(ctx context.Context, org string, event string, data interface{}) {
	log.JSON(fmt.Sprintf("Emit webhook '%s' for '%s'", event, org), data, ctx)

	db := datastore.New(ctx)
	db.SetNamespace(org)

	hooks := make([]*webhook.Webhook, 0)
	_, err := webhook.Query(db).GetAll(&hooks)
	if err != nil {
		log.Warn("Failed to retrieve webhooks for organization '%s': %v", org, err, ctx)
	}

	if len(hooks) == 0 {
		log.Debug("No webhooks defined for organization '%s'", org, ctx)
		return
	}

	client := createClient(ctx)

	for _, hook := range hooks {

		if hook.All {
			client.Post(hook.Url, Payload{
				Data:        data,
				AccessToken: hook.AccessToken,
			})
			continue
		}

		if enabled, ok := hook.Events[event]; ok && enabled {
			client.Post(hook.Url, Payload{
				Data:        data,
				AccessToken: hook.AccessToken,
			})
		}
	}
})

Fire webhooks

Functions

This section is empty.

Types

type Client

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

func (*Client) Post

func (c *Client) Post(url string, data interface{}) error

type Payload

type Payload struct {
	Data        interface{} `json:"data"`
	AccessToken string      `json:"accessToken"`
}

Jump to

Keyboard shortcuts

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