Add membership and host to user webhook payload

Nest membership ID, role, and state into a membership sub-object
in the user webhook payload. Also emit user:updated webhook when
the membership role is changed. Add X-Probo-Webhook-Host header
to webhook HTTP calls. Skip delete webhook when membership is
not found in SCIM user deletion.

Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
Sacha Al Himdani
2026-04-13 17:00:22 +02:00
parent 0826f28867
commit 06c0972551
5 changed files with 71 additions and 30 deletions

View File

@@ -43,6 +43,7 @@ type (
logger *log.Logger
httpClient *http.Client
encryptionKey cipher.EncryptionKey
host string
cache sync.Map
cacheCreatedAt time.Time
cacheTTL time.Duration
@@ -60,6 +61,7 @@ type (
Timeout time.Duration
CacheTTL time.Duration
EncryptionKey cipher.EncryptionKey
Host string
}
pendingDelivery struct {
@@ -88,6 +90,7 @@ func NewSender(pg *pg.Client, logger *log.Logger, cfg Config) *Sender {
logger: logger,
httpClient: httpclient.DefaultPooledClient(httpclient.WithLogger(logger)),
encryptionKey: cfg.EncryptionKey,
host: cfg.Host,
cacheCreatedAt: time.Now(),
cacheTTL: cfg.CacheTTL,
interval: cfg.Interval,
@@ -310,6 +313,7 @@ func (s *Sender) doHTTPCall(
req.Header.Set("X-Probo-Webhook-Organization-Id", webhookData.OrganizationID.String())
req.Header.Set("X-Probo-Webhook-Timestamp", timestamp)
req.Header.Set("X-Probo-Webhook-Signature", signature)
req.Header.Set("X-Probo-Webhook-Host", s.host)
resp, err := s.httpClient.Do(req)
if err != nil {