~sircmpwn/lists.sr.ht

1cb00ed5929a1e0184e9d12880887a1d7aa10571 — Thorben Günther 1 year, 6 months ago a438d6b 0.57.5
api/webhooks: Deliver PATCHSET_RECEIVED user webhooks
2 files changed, 19 insertions(+), 0 deletions(-)

M api/graph/schema.resolvers.go
M api/webhooks/webhooks.go
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +7 -0
@@ 1288,6 1288,13 @@ func (r *mutationResolver) TriggerUserEmailWebhooks(ctx context.Context, emailID
		return nil, err
	}
	webhooks.DeliverUserEmailEvent(ctx, model.WebhookEventEmailReceived, email)
	if email.PatchsetID != nil {
		patchset, err := loaders.ForContext(ctx).PatchsetsByID.Load(*email.PatchsetID)
		if err != nil {
			return nil, err
		}
		webhooks.DeliverUserPatchsetEvent(ctx, model.WebhookEventPatchsetReceived, patchset)
	}
	return email, nil
}


M api/webhooks/webhooks.go => api/webhooks/webhooks.go +12 -0
@@ 73,6 73,18 @@ func DeliverUserEmailEvent(ctx context.Context,
	deliverUserWebhook(ctx, event, &payload, payloadUUID)
}

func DeliverUserPatchsetEvent(ctx context.Context,
	event model.WebhookEvent, patchset *model.Patchset) {
	payloadUUID := uuid.New()
	payload := model.PatchsetEvent{
		UUID:     payloadUUID.String(),
		Event:    event,
		Date:     time.Now().UTC(),
		Patchset: patchset,
	}
	deliverUserWebhook(ctx, event, &payload, payloadUUID)
}

func DeliverMailingListEvent(ctx context.Context,
	event model.WebhookEvent, list *model.MailingList) {
	payloadUUID := uuid.New()