diff --git a/src/Umbraco.Core/Webhooks/WebhookEventCollectionBuilderCmsExtensions.cs b/src/Umbraco.Core/Webhooks/WebhookEventCollectionBuilderCmsExtensions.cs index 361891de6a13..679e105b72d5 100644 --- a/src/Umbraco.Core/Webhooks/WebhookEventCollectionBuilderCmsExtensions.cs +++ b/src/Umbraco.Core/Webhooks/WebhookEventCollectionBuilderCmsExtensions.cs @@ -9,6 +9,15 @@ namespace Umbraco.Cms.Core.DependencyInjection; /// public static class WebhookEventCollectionBuilderCmsExtensions { + private static readonly Type[] _defaultTypes = + [ + typeof(ContentDeletedWebhookEvent), + typeof(ContentPublishedWebhookEvent), + typeof(ContentUnpublishedWebhookEvent), + typeof(MediaDeletedWebhookEvent), + typeof(MediaSavedWebhookEvent), + ]; + /// /// Adds the default webhook events. /// @@ -21,12 +30,24 @@ public static class WebhookEventCollectionBuilderCmsExtensions /// public static WebhookEventCollectionBuilderCms AddDefault(this WebhookEventCollectionBuilderCms builder) { - builder.Builder - .Add() - .Add() - .Add() - .Add() - .Add(); + builder.Builder.Add(_defaultTypes); + + return builder; + } + + /// + /// Removes the default webhook events. + /// + /// The builder. + /// + /// The builder. + /// + public static WebhookEventCollectionBuilderCms RemoveDefault(this WebhookEventCollectionBuilderCms builder) + { + foreach (Type type in _defaultTypes) + { + builder.Builder.Remove(type); + } return builder; }