mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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. 
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user