Add user webhooks (#21563)

Currently we can add webhooks for organizations but not for users. This
PR adds the latter. You can access it from the current users settings.


![grafik](https://user-images.githubusercontent.com/1666336/197391408-15dfdc23-b476-4d0c-82f7-9bc9b065988f.png)
This commit is contained in:
KN4CK3R 2023-03-10 15:28:32 +01:00 committed by GitHub
parent dad057b639
commit 2173f14708
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 737 additions and 234 deletions

View file

@ -101,7 +101,7 @@ func GenerateWebhooks(ctx context.Context, templateRepo, generateRepo *repo_mode
HookEvent: templateWebhook.HookEvent,
IsActive: templateWebhook.IsActive,
Type: templateWebhook.Type,
OrgID: templateWebhook.OrgID,
OwnerID: templateWebhook.OwnerID,
Events: templateWebhook.Events,
Meta: templateWebhook.Meta,
})

View file

@ -229,16 +229,16 @@ func PrepareWebhooks(ctx context.Context, source EventSource, event webhook_modu
owner = source.Repository.MustOwner(ctx)
}
// check if owner is an org and append additional webhooks
if owner != nil && owner.IsOrganization() {
orgHooks, err := webhook_model.ListWebhooksByOpts(ctx, &webhook_model.ListWebhookOptions{
OrgID: owner.ID,
// append additional webhooks of a user or organization
if owner != nil {
ownerHooks, err := webhook_model.ListWebhooksByOpts(ctx, &webhook_model.ListWebhookOptions{
OwnerID: owner.ID,
IsActive: util.OptionalBoolTrue,
})
if err != nil {
return fmt.Errorf("ListWebhooksByOpts: %w", err)
}
ws = append(ws, orgHooks...)
ws = append(ws, ownerHooks...)
}
// Add any admin-defined system webhooks