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; /// </summary> public static class WebhookEventCollectionBuilderCmsExtensions { + private static readonly Type[] _defaultTypes = + [ + typeof(ContentDeletedWebhookEvent), + typeof(ContentPublishedWebhookEvent), + typeof(ContentUnpublishedWebhookEvent), + typeof(MediaDeletedWebhookEvent), + typeof(MediaSavedWebhookEvent), + ]; + /// <summary> /// Adds the default webhook events. /// </summary> @@ -21,12 +30,24 @@ public static class WebhookEventCollectionBuilderCmsExtensions /// </remarks> public static WebhookEventCollectionBuilderCms AddDefault(this WebhookEventCollectionBuilderCms builder) { - builder.Builder - .Add<ContentDeletedWebhookEvent>() - .Add<ContentPublishedWebhookEvent>() - .Add<ContentUnpublishedWebhookEvent>() - .Add<MediaDeletedWebhookEvent>() - .Add<MediaSavedWebhookEvent>(); + builder.Builder.Add(_defaultTypes); + + return builder; + } + + /// <summary> + /// Removes the default webhook events. + /// </summary> + /// <param name="builder">The builder.</param> + /// <returns> + /// The builder. + /// </returns> + public static WebhookEventCollectionBuilderCms RemoveDefault(this WebhookEventCollectionBuilderCms builder) + { + foreach (Type type in _defaultTypes) + { + builder.Builder.Remove(type); + } return builder; }