aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorKN4CK3R2023-03-10 15:28:32 +0100
committerGitHub2023-03-10 08:28:32 -0600
commit2173f14708ff3b35d7821fc9b6dcb5fcd06b8494 (patch)
tree5dcb735cc960095f9f8e114a1d896bb80df66ba9 /services
parentdad057b6393548ad389ead07c2cce5b3ac2811e0 (diff)
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)
Diffstat (limited to 'services')
-rw-r--r--services/repository/hooks.go2
-rw-r--r--services/webhook/webhook.go10
2 files changed, 6 insertions, 6 deletions
diff --git a/services/repository/hooks.go b/services/repository/hooks.go
index a8b6f7a62..8506fa341 100644
--- a/services/repository/hooks.go
+++ b/services/repository/hooks.go
@@ -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,
})
diff --git a/services/webhook/webhook.go b/services/webhook/webhook.go
index afd8e3c10..b862d5bff 100644
--- a/services/webhook/webhook.go
+++ b/services/webhook/webhook.go
@@ -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