mirror of
https://github.com/teamhanko/hanko.git
synced 2025-10-28 06:37:57 +08:00
* add tests for webhooks * improve error handling when context does not contain webhook manager * add logging to worker and fix nesting error overwrite * remove enable and disable methods in favor for update method * move data in jwt from subject claim to custom `data` claim * add event in jwt to custom `evt` claim * change webhook trigger to only fire once per hook (was once per subscribed event in hook before) Closes #692
22 lines
498 B
Go
22 lines
498 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/teamhanko/hanko/backend/webhooks"
|
|
"github.com/teamhanko/hanko/backend/webhooks/events"
|
|
)
|
|
|
|
func TriggerWebhooks(ctx echo.Context, evt events.Event, data interface{}) error {
|
|
webhookCtx := ctx.Get("webhook_manager")
|
|
if webhookCtx == nil {
|
|
return fmt.Errorf("unable to load webhooks manager from webhook middleware")
|
|
}
|
|
|
|
webhookManager := webhookCtx.(webhooks.Manager)
|
|
webhookManager.Trigger(evt, data)
|
|
|
|
return nil
|
|
|
|
}
|