diff --git a/src/Umbraco.Core/Constants-WebhookEvents.cs b/src/Umbraco.Core/Constants-WebhookEvents.cs index afd57b5188ef..41b9849f08f1 100644 --- a/src/Umbraco.Core/Constants-WebhookEvents.cs +++ b/src/Umbraco.Core/Constants-WebhookEvents.cs @@ -6,6 +6,57 @@ public static class WebhookEvents { public static class Aliases { + + /// + /// Webhook event alias for content versions deleted + /// + public const string ContentDeletedVersions = "Umbraco.ContentDeletedVersions"; + + /// + /// Webhook event alias for content blueprint saved + /// + public const string ContentSavedBlueprint = "Umbraco.ContentSavedBlueprint"; + + /// + /// Webhook event alias for content blueprint deleted + /// + public const string ContentDeletedBlueprint = "Umbraco.ContentDeletedBlueprint"; + + /// + /// Webhook event alias for content moved into the recycle bin. + /// + public const string ContentMovedToRecycleBin = "Umbraco.ContentMovedToRecycleBin"; + + /// + /// Webhook event alias for content sorted. + /// + public const string ContentSorted = "Umbraco.ContentSorted"; + + /// + /// Webhook event alias for content moved. + /// + public const string ContentMoved = "Umbraco.ContentMoved"; + + /// + /// Webhook event alias for content copied. + /// + public const string ContentCopied = "Umbraco.ContentCopied"; + + /// + /// Webhook event alias for content emptied recycle bin. + /// + public const string ContentEmptiedRecycleBin = "Umbraco.ContentEmptiedRecycleBin"; + + /// + /// Webhook event alias for content rolled back. + /// + public const string ContentRolledBack = "Umbraco.ContentRolledBack"; + + /// + /// Webhook event alias for content saved. + /// + public const string ContentSaved = "Umbraco.ContentSaved"; + /// /// Webhook event alias for content publish. /// diff --git a/src/Umbraco.Core/EmbeddedResources/Lang/en.xml b/src/Umbraco.Core/EmbeddedResources/Lang/en.xml index 572fe05dd4bc..492cb762cf6b 100644 --- a/src/Umbraco.Core/EmbeddedResources/Lang/en.xml +++ b/src/Umbraco.Core/EmbeddedResources/Lang/en.xml @@ -1941,6 +1941,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont Create header Logs No webhook headers have been added + No events were found. Add language diff --git a/src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml b/src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml index 33901735eec1..12fdf928c236 100644 --- a/src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml +++ b/src/Umbraco.Core/EmbeddedResources/Lang/en_us.xml @@ -2023,6 +2023,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont Create header Logs No webhook headers have been added + No events were found. Add language diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentCopiedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentCopiedWebhookEvent.cs new file mode 100644 index 000000000000..3d6f0163d70b --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentCopiedWebhookEvent.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Copied", Constants.WebhookEvents.Types.Content)] +public class ContentCopiedWebhookEvent : WebhookEventBase +{ + public ContentCopiedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentCopied; + + public override object? ConvertNotificationToRequestPayload(ContentCopiedNotification notification) + { + return new + { + notification.Copy, + notification.Original, + notification.ParentId, + notification.RelateToOriginal + }; + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentDeletedBlueprintWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentDeletedBlueprintWebhookEvent.cs new file mode 100644 index 000000000000..996b8abd15d9 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentDeletedBlueprintWebhookEvent.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Template [Blueprint] Deleted", Constants.WebhookEvents.Types.Content)] +public class ContentDeletedBlueprintWebhookEvent : WebhookEventContentBase +{ + public ContentDeletedBlueprintWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentDeletedBlueprint; + + protected override IEnumerable GetEntitiesFromNotification(ContentDeletedBlueprintNotification notification) => + notification.DeletedBlueprints; + + protected override object ConvertEntityToRequestPayload(IContent entity) => entity; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentDeletedVersionsWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentDeletedVersionsWebhookEvent.cs new file mode 100644 index 000000000000..c543bfe3cad7 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentDeletedVersionsWebhookEvent.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Versions Deleted", Constants.WebhookEvents.Types.Content)] +public class ContentDeletedVersionsWebhookEvent : WebhookEventBase +{ + public ContentDeletedVersionsWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentDeletedVersions; + + public override object? ConvertNotificationToRequestPayload(ContentDeletedVersionsNotification notification) + { + return new + { + notification.Id, + notification.DeletePriorVersions, + notification.SpecificVersion, + notification.DateToRetain + }; + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/ContentDeleteWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentDeletedWebhookEvent.cs similarity index 77% rename from src/Umbraco.Core/Webhooks/Events/ContentDeleteWebhookEvent.cs rename to src/Umbraco.Core/Webhooks/Events/Content/ContentDeletedWebhookEvent.cs index 85a1f39ba9d4..128282299566 100644 --- a/src/Umbraco.Core/Webhooks/Events/ContentDeleteWebhookEvent.cs +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentDeletedWebhookEvent.cs @@ -5,12 +5,12 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Sync; -namespace Umbraco.Cms.Core.Webhooks.Events; +namespace Umbraco.Cms.Core.Webhooks.Events.Content; -[WebhookEvent("Content was deleted", Constants.WebhookEvents.Types.Content)] -public class ContentDeleteWebhookEvent : WebhookEventContentBase +[WebhookEvent("Content Deleted", Constants.WebhookEvents.Types.Content)] +public class ContentDeletedWebhookEvent : WebhookEventContentBase { - public ContentDeleteWebhookEvent( + public ContentDeletedWebhookEvent( IWebhookFiringService webhookFiringService, IWebhookService webhookService, IOptionsMonitor webhookSettings, diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentEmptiedRecycleBinWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentEmptiedRecycleBinWebhookEvent.cs new file mode 100644 index 000000000000..8670d23c49e5 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentEmptiedRecycleBinWebhookEvent.cs @@ -0,0 +1,41 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.DeliveryApi; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.PublishedCache; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Recycle Bin Emptied", Constants.WebhookEvents.Types.Content)] +public class ContentEmptiedRecycleBinWebhookEvent : WebhookEventContentBase +{ + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; + private readonly IApiContentBuilder _apiContentBuilder; + + public ContentEmptiedRecycleBinWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor, + IPublishedSnapshotAccessor publishedSnapshotAccessor, + IApiContentBuilder apiContentBuilder) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + _publishedSnapshotAccessor = publishedSnapshotAccessor; + _apiContentBuilder = apiContentBuilder; + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentEmptiedRecycleBin; + + protected override IEnumerable GetEntitiesFromNotification(ContentEmptiedRecycleBinNotification notification) => + notification.DeletedEntities; + + protected override object? ConvertEntityToRequestPayload(IContent entity) => entity; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentMovedToRecycleBinWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentMovedToRecycleBinWebhookEvent.cs new file mode 100644 index 000000000000..6ed74d8c66e4 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentMovedToRecycleBinWebhookEvent.cs @@ -0,0 +1,29 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Moved to Recycle Bin", Constants.WebhookEvents.Types.Content)] +public class ContentMovedToRecycleBinWebhookEvent : WebhookEventBase +{ + public ContentMovedToRecycleBinWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentMovedToRecycleBin; + + public override object? ConvertNotificationToRequestPayload(ContentMovedToRecycleBinNotification notification) + => notification.MoveInfoCollection; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentMovedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentMovedWebhookEvent.cs new file mode 100644 index 000000000000..46d487c499e0 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentMovedWebhookEvent.cs @@ -0,0 +1,29 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Moved", Constants.WebhookEvents.Types.Content)] +public class ContentMovedWebhookEvent : WebhookEventBase +{ + public ContentMovedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentMoved; + + public override object? ConvertNotificationToRequestPayload(ContentMovedNotification notification) + => notification.MoveInfoCollection; +} diff --git a/src/Umbraco.Core/Webhooks/Events/ContentPublishWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentPublishedWebhookEvent.cs similarity index 86% rename from src/Umbraco.Core/Webhooks/Events/ContentPublishWebhookEvent.cs rename to src/Umbraco.Core/Webhooks/Events/Content/ContentPublishedWebhookEvent.cs index e1ba7125ec78..5847fb450e6c 100644 --- a/src/Umbraco.Core/Webhooks/Events/ContentPublishWebhookEvent.cs +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentPublishedWebhookEvent.cs @@ -8,15 +8,15 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Sync; -namespace Umbraco.Cms.Core.Webhooks.Events; +namespace Umbraco.Cms.Core.Webhooks.Events.Content; -[WebhookEvent("Content was published", Constants.WebhookEvents.Types.Content)] -public class ContentPublishWebhookEvent : WebhookEventContentBase +[WebhookEvent("Content Published", Constants.WebhookEvents.Types.Content)] +public class ContentPublishedWebhookEvent : WebhookEventContentBase { private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private readonly IApiContentBuilder _apiContentBuilder; - public ContentPublishWebhookEvent( + public ContentPublishedWebhookEvent( IWebhookFiringService webhookFiringService, IWebhookService webhookService, IOptionsMonitor webhookSettings, diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentRolledBack.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentRolledBack.cs new file mode 100644 index 000000000000..f38ff571f908 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentRolledBack.cs @@ -0,0 +1,52 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.DeliveryApi; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Models.PublishedContent; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.PublishedCache; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Rolled Back", Constants.WebhookEvents.Types.Content)] +public class ContentRolledBackWebhookEvent : WebhookEventContentBase +{ + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; + private readonly IApiContentBuilder _apiContentBuilder; + + public ContentRolledBackWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor, + IPublishedSnapshotAccessor publishedSnapshotAccessor, + IApiContentBuilder apiContentBuilder) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + _publishedSnapshotAccessor = publishedSnapshotAccessor; + _apiContentBuilder = apiContentBuilder; + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentRolledBack; + + protected override IEnumerable GetEntitiesFromNotification(ContentRolledBackNotification notification) => + new List { notification.Entity }; + + protected override object? ConvertEntityToRequestPayload(IContent entity) + { + if (_publishedSnapshotAccessor.TryGetPublishedSnapshot(out IPublishedSnapshot? publishedSnapshot) is false || publishedSnapshot!.Content is null) + { + return null; + } + + // Get preview/saved version of content for a rollback + IPublishedContent? publishedContent = publishedSnapshot.Content.GetById(true, entity.Key); + return publishedContent is null ? null : _apiContentBuilder.Build(publishedContent); + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentSavedBlueprintWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentSavedBlueprintWebhookEvent.cs new file mode 100644 index 000000000000..40630b453f39 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentSavedBlueprintWebhookEvent.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Template [Blueprint] Saved", Constants.WebhookEvents.Types.Content)] +public class ContentSavedBlueprintWebhookEvent : WebhookEventContentBase +{ + public ContentSavedBlueprintWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentSavedBlueprint; + + protected override IEnumerable + GetEntitiesFromNotification(ContentSavedBlueprintNotification notification) + => new List { notification.SavedBlueprint }; + + protected override object ConvertEntityToRequestPayload(IContent entity) => entity; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentSavedWebhookEvent.cs new file mode 100644 index 000000000000..fac16de822e5 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentSavedWebhookEvent.cs @@ -0,0 +1,52 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.DeliveryApi; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Models.PublishedContent; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.PublishedCache; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Saved", Constants.WebhookEvents.Types.Content)] +public class ContentSavedWebhookEvent : WebhookEventContentBase +{ + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; + private readonly IApiContentBuilder _apiContentBuilder; + + public ContentSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor, + IPublishedSnapshotAccessor publishedSnapshotAccessor, + IApiContentBuilder apiContentBuilder) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + _publishedSnapshotAccessor = publishedSnapshotAccessor; + _apiContentBuilder = apiContentBuilder; + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentSaved; + + protected override IEnumerable GetEntitiesFromNotification(ContentSavedNotification notification) => + notification.SavedEntities; + + protected override object? ConvertEntityToRequestPayload(IContent entity) + { + if (_publishedSnapshotAccessor.TryGetPublishedSnapshot(out IPublishedSnapshot? publishedSnapshot) is false || publishedSnapshot!.Content is null) + { + return null; + } + + // Get preview/saved version of content + IPublishedContent? publishedContent = publishedSnapshot.Content.GetById(true, entity.Key); + return publishedContent is null ? null : _apiContentBuilder.Build(publishedContent); + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/Content/ContentSortedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentSortedWebhookEvent.cs new file mode 100644 index 000000000000..d2a95028e2fd --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentSortedWebhookEvent.cs @@ -0,0 +1,53 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.DeliveryApi; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Models.PublishedContent; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.PublishedCache; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Content; + +[WebhookEvent("Content Sorted", Constants.WebhookEvents.Types.Content)] +public class ContentSortedWebhookEvent : WebhookEventBase +{ + private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; + private readonly IApiContentBuilder _apiContentBuilder; + + public ContentSortedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webhookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor, + IPublishedSnapshotAccessor publishedSnapshotAccessor, + IApiContentBuilder apiContentBuilder) + : base( + webhookFiringService, + webhookService, + webhookSettings, + serverRoleAccessor) + { + _publishedSnapshotAccessor = publishedSnapshotAccessor; + _apiContentBuilder = apiContentBuilder; + } + + public override string Alias => Constants.WebhookEvents.Aliases.ContentSorted; + + public override object? ConvertNotificationToRequestPayload(ContentSortedNotification notification) + { + if (_publishedSnapshotAccessor.TryGetPublishedSnapshot(out IPublishedSnapshot? publishedSnapshot) is false || publishedSnapshot!.Content is null) + { + return null; + } + var sortedEntities = new List(); + foreach (var entity in notification.SortedEntities) + { + IPublishedContent? publishedContent = publishedSnapshot.Content.GetById(entity.Key); + object? payload = publishedContent is null ? null : _apiContentBuilder.Build(publishedContent); + sortedEntities.Add(payload); + } + return sortedEntities; + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/ContentUnpublishWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Content/ContentUnpublishedWebhookEvent.cs similarity index 76% rename from src/Umbraco.Core/Webhooks/Events/ContentUnpublishWebhookEvent.cs rename to src/Umbraco.Core/Webhooks/Events/Content/ContentUnpublishedWebhookEvent.cs index 76499eb277d5..81245f9b75b2 100644 --- a/src/Umbraco.Core/Webhooks/Events/ContentUnpublishWebhookEvent.cs +++ b/src/Umbraco.Core/Webhooks/Events/Content/ContentUnpublishedWebhookEvent.cs @@ -5,12 +5,12 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Sync; -namespace Umbraco.Cms.Core.Webhooks.Events; +namespace Umbraco.Cms.Core.Webhooks.Events.Content; -[WebhookEvent("Content was unpublished", Constants.WebhookEvents.Types.Content)] -public class ContentUnpublishWebhookEvent : WebhookEventContentBase +[WebhookEvent("Content Unpublished", Constants.WebhookEvents.Types.Content)] +public class ContentUnpublishedWebhookEvent : WebhookEventContentBase { - public ContentUnpublishWebhookEvent( + public ContentUnpublishedWebhookEvent( IWebhookFiringService webhookFiringService, IWebhookService webhookService, IOptionsMonitor webhookSettings, diff --git a/src/Umbraco.Core/Webhooks/Events/DataType/DataTypeDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/DataType/DataTypeDeletedWebhookEvent.cs new file mode 100644 index 000000000000..b121c6f394dd --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/DataType/DataTypeDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.DataType; + +[WebhookEvent("Data Type Deleted")] +public class DataTypeDeletedWebhookEvent : WebhookEventBase +{ + public DataTypeDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "dataTypeDeleted"; + + public override object? ConvertNotificationToRequestPayload(DataTypeSavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/DataType/DataTypeMovedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/DataType/DataTypeMovedWebhookEvent.cs new file mode 100644 index 000000000000..03c0954305be --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/DataType/DataTypeMovedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.DataType; + +[WebhookEvent("Data Type Moved")] +public class DataTypeMovedWebhookEvent : WebhookEventBase +{ + public DataTypeMovedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "dataTypeMoved"; + + public override object? ConvertNotificationToRequestPayload(DataTypeMovedNotification notification) + => notification.MoveInfoCollection; +} diff --git a/src/Umbraco.Core/Webhooks/Events/DataType/DataTypeSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/DataType/DataTypeSavedWebhookEvent.cs new file mode 100644 index 000000000000..a6e5afe189af --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/DataType/DataTypeSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.DataType; + +[WebhookEvent("Data Type Saved")] +public class DataTypeSavedWebhookEvent : WebhookEventBase +{ + public DataTypeSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "dataTypeSaved"; + + public override object? ConvertNotificationToRequestPayload(DataTypeSavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Dictionary/DictionaryItemDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Dictionary/DictionaryItemDeletedWebhookEvent.cs new file mode 100644 index 000000000000..fa3c95cea55b --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Dictionary/DictionaryItemDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Dictionary; + +[WebhookEvent("Dictionary Item Deleted")] +public class DictionaryItemDeletedWebhookEvent : WebhookEventBase +{ + public DictionaryItemDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "dictionaryItemDeleted"; + + public override object? ConvertNotificationToRequestPayload(DictionaryItemDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Dictionary/DictionaryItemSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Dictionary/DictionaryItemSavedWebhookEvent.cs new file mode 100644 index 000000000000..7edd4e784926 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Dictionary/DictionaryItemSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Dictionary; + +[WebhookEvent("Dictionary Item Saved")] +public class DictionaryItemSavedWebhookEvent : WebhookEventBase +{ + public DictionaryItemSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "dictionaryItemSaved"; + + public override object? ConvertNotificationToRequestPayload(DictionaryItemSavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Domain/DomainDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Domain/DomainDeletedWebhookEvent.cs new file mode 100644 index 000000000000..30605a28de3e --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Domain/DomainDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Domain; + +[WebhookEvent("Domain Deleted")] +public class DomainDeletedWebhookEvent : WebhookEventBase +{ + public DomainDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "domainDeleted"; + + public override object? ConvertNotificationToRequestPayload(DomainDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Domain/DomainSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Domain/DomainSavedWebhookEvent.cs new file mode 100644 index 000000000000..5cd80f743b1b --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Domain/DomainSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Domain; + +[WebhookEvent("Domain Saved")] +public class DomainSavedWebhookEvent : WebhookEventBase +{ + public DomainSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "domainSaved"; + + public override object? ConvertNotificationToRequestPayload(DomainSavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Language/LanguageDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Language/LanguageDeletedWebhookEvent.cs new file mode 100644 index 000000000000..98ebd4d5c843 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Language/LanguageDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Language; + +[WebhookEvent("Language Deleted")] +public class LanguageDeletedWebhookEvent : WebhookEventBase +{ + public LanguageDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "languageDeleted"; + + public override object? ConvertNotificationToRequestPayload(LanguageDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Language/LanguageSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Language/LanguageSavedWebhookEvent.cs new file mode 100644 index 000000000000..ccc52f4245c5 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Language/LanguageSavedWebhookEvent.cs @@ -0,0 +1,26 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Language; + +[WebhookEvent("Language Saved")] +public class LanguageSavedWebhookEvent : WebhookEventBase +{ + public LanguageSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "languageSaved"; + + public override object? ConvertNotificationToRequestPayload(LanguageSavedNotification notification) + => notification.SavedEntities; +} + diff --git a/src/Umbraco.Core/Webhooks/Events/MediaDeleteWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Media/MediaDeletedWebhookEvent.cs similarity index 78% rename from src/Umbraco.Core/Webhooks/Events/MediaDeleteWebhookEvent.cs rename to src/Umbraco.Core/Webhooks/Events/Media/MediaDeletedWebhookEvent.cs index ba9fb2333a32..659917652dda 100644 --- a/src/Umbraco.Core/Webhooks/Events/MediaDeleteWebhookEvent.cs +++ b/src/Umbraco.Core/Webhooks/Events/Media/MediaDeletedWebhookEvent.cs @@ -5,12 +5,12 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Sync; -namespace Umbraco.Cms.Core.Webhooks.Events; +namespace Umbraco.Cms.Core.Webhooks.Events.Media; -[WebhookEvent("Media was deleted", Constants.WebhookEvents.Types.Media)] -public class MediaDeleteWebhookEvent : WebhookEventContentBase +[WebhookEvent("Media Deleted", Constants.WebhookEvents.Types.Media)] +public class MediaDeletedWebhookEvent : WebhookEventContentBase { - public MediaDeleteWebhookEvent( + public MediaDeletedWebhookEvent( IWebhookFiringService webhookFiringService, IWebhookService webhookService, IOptionsMonitor webhookSettings, diff --git a/src/Umbraco.Core/Webhooks/Events/Media/MediaEmptiedRecycleBinWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Media/MediaEmptiedRecycleBinWebhookEvent.cs new file mode 100644 index 000000000000..29d0e44e4623 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Media/MediaEmptiedRecycleBinWebhookEvent.cs @@ -0,0 +1,31 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Media; + +[WebhookEvent("Media Recycle Bin Emptied", Constants.WebhookEvents.Types.Media)] +public class MediaEmptiedRecycleBinWebhookEvent : WebhookEventContentBase +{ + public MediaEmptiedRecycleBinWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base( + webhookFiringService, + webHookService, + webhookSettings, + serverRoleAccessor) + { + } + + public override string Alias => "mediaEmptiedRecycleBin"; + + protected override IEnumerable GetEntitiesFromNotification(MediaEmptiedRecycleBinNotification notification) => notification.DeletedEntities; + + protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key }; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Media/MediaMovedToRecycleBinWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Media/MediaMovedToRecycleBinWebhookEvent.cs new file mode 100644 index 000000000000..1bd05c6d7b03 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Media/MediaMovedToRecycleBinWebhookEvent.cs @@ -0,0 +1,31 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Media; + +[WebhookEvent("Media Moved to Recycle Bin", Constants.WebhookEvents.Types.Media)] +public class MediaMovedToRecycleBinWebhookEvent : WebhookEventContentBase +{ + public MediaMovedToRecycleBinWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base( + webhookFiringService, + webHookService, + webhookSettings, + serverRoleAccessor) + { + } + + public override string Alias => "mediaMovedToRecycleBin"; + + protected override IEnumerable GetEntitiesFromNotification(MediaMovedToRecycleBinNotification notification) => notification.MoveInfoCollection.Select(x => x.Entity); + + protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key }; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Media/MediaMovedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Media/MediaMovedWebhookEvent.cs new file mode 100644 index 000000000000..60b235f4cc63 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Media/MediaMovedWebhookEvent.cs @@ -0,0 +1,31 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Media; + +[WebhookEvent("Media Moved", Constants.WebhookEvents.Types.Media)] +public class MediaMovedWebhookEvent : WebhookEventContentBase +{ + public MediaMovedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base( + webhookFiringService, + webHookService, + webhookSettings, + serverRoleAccessor) + { + } + + public override string Alias => "mediaMoved"; + + protected override IEnumerable GetEntitiesFromNotification(MediaMovedNotification notification) => notification.MoveInfoCollection.Select(x => x.Entity); + + protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key }; +} diff --git a/src/Umbraco.Core/Webhooks/Events/MediaSaveWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Media/MediaSavedWebhookEvent.cs similarity index 68% rename from src/Umbraco.Core/Webhooks/Events/MediaSaveWebhookEvent.cs rename to src/Umbraco.Core/Webhooks/Events/Media/MediaSavedWebhookEvent.cs index cea7181d5137..6c68e8edb146 100644 --- a/src/Umbraco.Core/Webhooks/Events/MediaSaveWebhookEvent.cs +++ b/src/Umbraco.Core/Webhooks/Events/Media/MediaSavedWebhookEvent.cs @@ -8,15 +8,15 @@ using Umbraco.Cms.Core.Services; using Umbraco.Cms.Core.Sync; -namespace Umbraco.Cms.Core.Webhooks.Events; +namespace Umbraco.Cms.Core.Webhooks.Events.Media; -[WebhookEvent("Media was saved", Constants.WebhookEvents.Types.Media)] -public class MediaSaveWebhookEvent : WebhookEventContentBase +[WebhookEvent("Media Saved", Constants.WebhookEvents.Types.Media)] +public class MediaSavedWebhookEvent : WebhookEventContentBase { private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor; private readonly IApiMediaBuilder _apiMediaBuilder; - public MediaSaveWebhookEvent( + public MediaSavedWebhookEvent( IWebhookFiringService webhookFiringService, IWebhookService webhookService, IOptionsMonitor webhookSettings, @@ -29,8 +29,8 @@ public MediaSaveWebhookEvent( webhookSettings, serverRoleAccessor) { - _publishedSnapshotAccessor = publishedSnapshotAccessor; - _apiMediaBuilder = apiMediaBuilder; + this._publishedSnapshotAccessor = publishedSnapshotAccessor; + this._apiMediaBuilder = apiMediaBuilder; } public override string Alias => Constants.WebhookEvents.Aliases.MediaSave; @@ -39,12 +39,12 @@ public MediaSaveWebhookEvent( protected override object? ConvertEntityToRequestPayload(IMedia entity) { - if (_publishedSnapshotAccessor.TryGetPublishedSnapshot(out IPublishedSnapshot? publishedSnapshot) is false || publishedSnapshot!.Content is null) + if (this._publishedSnapshotAccessor.TryGetPublishedSnapshot(out IPublishedSnapshot? publishedSnapshot) is false || publishedSnapshot!.Content is null) { return null; } IPublishedContent? publishedContent = publishedSnapshot.Media?.GetById(entity.Key); - return publishedContent is null ? null : _apiMediaBuilder.Build(publishedContent); + return publishedContent is null ? null : this._apiMediaBuilder.Build(publishedContent); } } diff --git a/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeChangedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeChangedWebhookEvent.cs new file mode 100644 index 000000000000..23decd003229 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeChangedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.MediaType; + +[WebhookEvent("Media Type Changed")] +public class MediaTypeChangedWebhookEvent : WebhookEventBase +{ + public MediaTypeChangedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "mediaTypeChanged"; + + public override object? ConvertNotificationToRequestPayload(MediaTypeChangedNotification notification) + => notification.Changes; +} diff --git a/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeDeletedWebhookEvent.cs new file mode 100644 index 000000000000..7b46967d06bd --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.MediaType; + +[WebhookEvent("Media Type Deleted")] +public class MediaTypeDeletedWebhookEvent : WebhookEventBase +{ + public MediaTypeDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "mediaTypeDeleted"; + + public override object? ConvertNotificationToRequestPayload(MediaTypeDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeMovedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeMovedWebhookEvent.cs new file mode 100644 index 000000000000..ae2a35995ea4 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeMovedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.MediaType; + +[WebhookEvent("Media Type Moved")] +public class MediaTypeMovedWebhookEvent : WebhookEventBase +{ + public MediaTypeMovedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "mediaTypeMoved"; + + public override object? ConvertNotificationToRequestPayload(MediaTypeMovedNotification notification) + => notification.MoveInfoCollection; +} diff --git a/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeSavedWebhookEvent.cs new file mode 100644 index 000000000000..818b38f71b17 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/MediaType/MediaTypeSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.MediaType; + +[WebhookEvent("Media Type Saved")] +public class MediaTypeSavedWebhookEvent : WebhookEventBase +{ + public MediaTypeSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "mediaTypeSaved"; + + public override object? ConvertNotificationToRequestPayload(MediaTypeSavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Member/AssignedMemberRolesWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Member/AssignedMemberRolesWebhookEvent.cs new file mode 100644 index 000000000000..4812bdcc7368 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Member/AssignedMemberRolesWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Member; + +[WebhookEvent("Member Roles Assigned")] +public class AssignedMemberRolesWebhookEvent : WebhookEventBase +{ + public AssignedMemberRolesWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "assignedMemberRoles"; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Member/ExportedMemberWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Member/ExportedMemberWebhookEvent.cs new file mode 100644 index 000000000000..3f72587c8fea --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Member/ExportedMemberWebhookEvent.cs @@ -0,0 +1,32 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Member; + +[WebhookEvent("Member Exported")] +public class ExportedMemberWebhookEvent : WebhookEventBase +{ + public ExportedMemberWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "exportedMember"; + + public override object? ConvertNotificationToRequestPayload(ExportedMemberNotification notification) + { + // No need to return the original member in the notification as well + return new + { + exportedMember = notification.Exported + }; + + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/Member/MemberDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Member/MemberDeletedWebhookEvent.cs new file mode 100644 index 000000000000..c29e22003f45 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Member/MemberDeletedWebhookEvent.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Member; + +[WebhookEvent("Member Deleted")] +public class MemberDeletedWebhookEvent : WebhookEventBase +{ + public MemberDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "memberDeleted"; + + public override object? ConvertNotificationToRequestPayload(MemberDeletedNotification notification) + { + // TODO: Map more stuff here + var result = notification.DeletedEntities.Select(entity => new + { + entity.Id, + entity.Key, + entity.Name, + entity.ContentTypeAlias, + entity.Email, + entity.Username, + entity.FailedPasswordAttempts + }); + + return result; + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/Member/MemberGroupDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Member/MemberGroupDeletedWebhookEvent.cs new file mode 100644 index 000000000000..ab41dfed07f5 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Member/MemberGroupDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Member; + +[WebhookEvent("Member Group Deleted")] +public class MemberGroupDeletedWebhookEvent : WebhookEventBase +{ + public MemberGroupDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "memberGroupDeleted"; + + public override object? ConvertNotificationToRequestPayload(MemberGroupDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Member/MemberGroupSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Member/MemberGroupSavedWebhookEvent.cs new file mode 100644 index 000000000000..19d3e7d4b293 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Member/MemberGroupSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Member; + +[WebhookEvent("Member Group Saved")] +public class MemberGroupSavedWebhookEvent : WebhookEventBase +{ + public MemberGroupSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "memberGroupSaved"; + + public override object? ConvertNotificationToRequestPayload(MemberGroupSavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Member/MemberSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Member/MemberSavedWebhookEvent.cs new file mode 100644 index 000000000000..edb82cb51843 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Member/MemberSavedWebhookEvent.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Member; + +[WebhookEvent("Member Saved")] +public class MemberSavedWebhookEvent : WebhookEventBase +{ + public MemberSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "memberSaved"; + + public override object? ConvertNotificationToRequestPayload(MemberSavedNotification notification) + { + // TODO: Map more stuff here + var result = notification.SavedEntities.Select(entity => new + { + entity.Id, + entity.Key, + entity.Name, + entity.ContentTypeAlias, + entity.Email, + entity.Username, + entity.FailedPasswordAttempts + }); + + return result; + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/Member/RemovedMemberRolesWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Member/RemovedMemberRolesWebhookEvent.cs new file mode 100644 index 000000000000..8925b240597d --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Member/RemovedMemberRolesWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Member; + +[WebhookEvent("Member Roles Removed")] +public class RemovedMemberRolesWebhookEvent : WebhookEventBase +{ + public RemovedMemberRolesWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "removedMemberRoles"; +} diff --git a/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeChangedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeChangedWebhookEvent.cs new file mode 100644 index 000000000000..68c4424e484b --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeChangedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.MemberType; + +[WebhookEvent("Member Type Changed")] +public class MemberTypeChangedWebhookEvent : WebhookEventBase +{ + public MemberTypeChangedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "memberTypeChanged"; + + public override object? ConvertNotificationToRequestPayload(MemberTypeChangedNotification notification) + => notification.Changes; +} diff --git a/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeDeletedWebhookEvent.cs new file mode 100644 index 000000000000..005143826cae --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.MemberType; + +[WebhookEvent("Member Type Deleted")] +public class MemberTypeDeletedWebhookEvent : WebhookEventBase +{ + public MemberTypeDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "memberTypeDeleted"; + + public override object? ConvertNotificationToRequestPayload(MemberTypeDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeMovedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeMovedWebhookEvent.cs new file mode 100644 index 000000000000..ddef29a0c2f5 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeMovedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.MemberType; + +[WebhookEvent("Member Type Moved")] +public class MemberTypeMovedWebhookEvent : WebhookEventBase +{ + public MemberTypeMovedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "memberTypeMoved"; + + public override object? ConvertNotificationToRequestPayload(MemberTypeMovedNotification notification) + => notification.MoveInfoCollection; +} diff --git a/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeSavedWebhookEvent.cs new file mode 100644 index 000000000000..db4bcf8ad4a2 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/MemberType/MemberTypeSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.MemberType; + +[WebhookEvent("Member Type Saved")] +public class MemberTypeSavedWebhookEvent : WebhookEventBase +{ + public MemberTypeSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "memberTypeSaved"; + + public override object? ConvertNotificationToRequestPayload(MemberTypeSavedNotification notification) => + notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Package/ImportedPackageWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Package/ImportedPackageWebhookEvent.cs new file mode 100644 index 000000000000..8495dde4c2d9 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Package/ImportedPackageWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Package; + +[WebhookEvent("Package Imported")] +public class ImportedPackageWebhookEvent : WebhookEventBase +{ + public ImportedPackageWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "packageImported"; +} diff --git a/src/Umbraco.Core/Webhooks/Events/PublicAccess/PublicAccessEntryDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/PublicAccess/PublicAccessEntryDeletedWebhookEvent.cs new file mode 100644 index 000000000000..00f5a2ca86f7 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/PublicAccess/PublicAccessEntryDeletedWebhookEvent.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.PublicAccess; + +[WebhookEvent("Public Access Entry Deleted")] +public class PublicAccessEntryDeletedWebhookEvent : WebhookEventBase +{ + public PublicAccessEntryDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "publicAccessEntryDeleted"; + + public override object? ConvertNotificationToRequestPayload(PublicAccessEntryDeletedNotification notification) => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/PublicAccess/PublicAccessEntrySavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/PublicAccess/PublicAccessEntrySavedWebhookEvent.cs new file mode 100644 index 000000000000..3977db2832b5 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/PublicAccess/PublicAccessEntrySavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.PublicAccess; + +[WebhookEvent("Public Access Entry Saved")] +public class PublicAccessEntrySavedWebhookEvent : WebhookEventBase +{ + public PublicAccessEntrySavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "publicAccessEntrySaved"; + + public override object? ConvertNotificationToRequestPayload(PublicAccessEntrySavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Relation/RelationDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Relation/RelationDeletedWebhookEvent.cs new file mode 100644 index 000000000000..2ade4bd08e7b --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Relation/RelationDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Relation; + +[WebhookEvent("Relation Deleted")] +public class RelationDeletedWebhookEvent : WebhookEventBase +{ + public RelationDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "relationDeleted"; + + public override object? ConvertNotificationToRequestPayload(RelationDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Relation/RelationSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Relation/RelationSavedWebhookEvent.cs new file mode 100644 index 000000000000..4cc775aa219d --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Relation/RelationSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Relation; + +[WebhookEvent("Relation Saved")] +public class RelationSavedWebhookEvent : WebhookEventBase +{ + public RelationSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "relationSaved"; + + public override object? ConvertNotificationToRequestPayload(RelationSavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/RelationType/RelationTypeDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/RelationType/RelationTypeDeletedWebhookEvent.cs new file mode 100644 index 000000000000..41f9619a4165 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/RelationType/RelationTypeDeletedWebhookEvent.cs @@ -0,0 +1,26 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.RelationType; + +[WebhookEvent("Relation Type Deleted")] +public class RelationTypeDeletedWebhookEvent : WebhookEventBase +{ + public RelationTypeDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + + public override string Alias => "relationTypeDeleted"; + + public override object? ConvertNotificationToRequestPayload(RelationTypeDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/RelationType/RelationTypeSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/RelationType/RelationTypeSavedWebhookEvent.cs new file mode 100644 index 000000000000..915e95c6cbb6 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/RelationType/RelationTypeSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.RelationType; + +[WebhookEvent("Relation Type Saved")] +public class RelationTypeSavedWebhookEvent : WebhookEventBase +{ + public RelationTypeSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "relationTypeSaved"; + + public override object? ConvertNotificationToRequestPayload(RelationTypeSavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Script/ScriptDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Script/ScriptDeletedWebhookEvent.cs new file mode 100644 index 000000000000..1dad592cb1ec --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Script/ScriptDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Script; + +[WebhookEvent("Script Deleted")] +public class ScriptDeletedWebhookEvent : WebhookEventBase +{ + public ScriptDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "scriptDeleted"; + + public override object? ConvertNotificationToRequestPayload(ScriptDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Script/ScriptSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Script/ScriptSavedWebhookEvent.cs new file mode 100644 index 000000000000..4d026b9f6c3c --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Script/ScriptSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Script; + +[WebhookEvent("Script Saved")] +public class ScriptSavedWebhookEvent : WebhookEventBase +{ + public ScriptSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "scriptSaved"; + + public override object? ConvertNotificationToRequestPayload(ScriptDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Stylesheet/StylesheetDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Stylesheet/StylesheetDeletedWebhookEvent.cs new file mode 100644 index 000000000000..5214dc39cb69 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Stylesheet/StylesheetDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Stylesheet; + +[WebhookEvent("Stylesheet Deleted")] +public class StylesheetDeletedWebhookEvent : WebhookEventBase +{ + public StylesheetDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "stylesheetDeleted"; + + public override object? ConvertNotificationToRequestPayload(StylesheetDeletedNotification notification) => + notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Stylesheet/StylesheetSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Stylesheet/StylesheetSavedWebhookEvent.cs new file mode 100644 index 000000000000..a135f701319a --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Stylesheet/StylesheetSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Stylesheet; + +[WebhookEvent("Stylesheet Saved")] +public class StylesheetSavedWebhookEvent : WebhookEventBase +{ + public StylesheetSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "stylesheetSaved"; + + public override object? ConvertNotificationToRequestPayload(StylesheetSavedNotification notification) + => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Template/PartialViewDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Template/PartialViewDeletedWebhookEvent.cs new file mode 100644 index 000000000000..1f3fc756fbbf --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Template/PartialViewDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Template; + +[WebhookEvent("Partial View Deleted")] +public class PartialViewDeletedWebhookEvent : WebhookEventBase +{ + public PartialViewDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "partialViewDeleted"; + + public override object? ConvertNotificationToRequestPayload(PartialViewDeletedNotification notification) + => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Template/PartialViewSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Template/PartialViewSavedWebhookEvent.cs new file mode 100644 index 000000000000..224d71c837af --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Template/PartialViewSavedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Template; + +[WebhookEvent("Partial View Saved")] +public class PartialViewSavedWebhookEvent : WebhookEventBase +{ + public PartialViewSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "partialViewSaved"; + + public override object? ConvertNotificationToRequestPayload(PartialViewSavedNotification notification) => + notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Template/TemplateDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Template/TemplateDeletedWebhookEvent.cs new file mode 100644 index 000000000000..2e18dd99323f --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Template/TemplateDeletedWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Template; + +[WebhookEvent("Template Deleted")] +public class TemplateDeletedWebhookEvent : WebhookEventBase +{ + public TemplateDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "templateDeleted"; + + public override object? ConvertNotificationToRequestPayload(TemplateDeletedNotification notification) => + notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/Template/TemplateSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/Template/TemplateSavedWebhookEvent.cs new file mode 100644 index 000000000000..3950e7e370e5 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/Template/TemplateSavedWebhookEvent.cs @@ -0,0 +1,33 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.Template; + +[WebhookEvent("Template Saved")] +public class TemplateSavedWebhookEvent : WebhookEventBase +{ + public TemplateSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "templateSaved"; + + public override object? ConvertNotificationToRequestPayload(TemplateSavedNotification notification) + { + // Create a new anonymous object with the properties we want + return new + { + notification.CreateTemplateForContentType, + notification.ContentTypeAlias, + notification.SavedEntities + }; + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/AssignedUserGroupPermissionsWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/AssignedUserGroupPermissionsWebhookEvent.cs new file mode 100644 index 000000000000..1b8b1002bcac --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/AssignedUserGroupPermissionsWebhookEvent.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Group Permissions Assigned")] +public class AssignedUserGroupPermissionsWebhookEvent : WebhookEventBase +{ + public AssignedUserGroupPermissionsWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "assignedUserGroupPermissions"; + + public override object? ConvertNotificationToRequestPayload(AssignedUserGroupPermissionsNotification notification) + => notification.EntityPermissions; +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserDeletedWebhookEvent.cs new file mode 100644 index 000000000000..3d7a6b2afa02 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserDeletedWebhookEvent.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Deleted")] +public class UserDeletedWebhookEvent : WebhookEventBase +{ + public UserDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userDeleted"; + + public override object? ConvertNotificationToRequestPayload(UserDeletedNotification notification) + { + // TODO: Map more stuff here + var result = notification.DeletedEntities.Select(entity => new + { + entity.Id, + entity.Key, + entity.Name, + entity.Language, + entity.Email, + entity.Username, + entity.FailedPasswordAttempts + }); + + return result; + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserForgotPasswordRequestedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserForgotPasswordRequestedWebhookEvent.cs new file mode 100644 index 000000000000..0426d7a1e673 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserForgotPasswordRequestedWebhookEvent.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Forgot Password Requested")] +public class UserForgotPasswordRequestedWebhookEvent : WebhookEventBase +{ + public UserForgotPasswordRequestedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userForgotPasswordRequested"; + +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserForgottenPasswordRequestedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserForgottenPasswordRequestedWebhookEvent.cs new file mode 100644 index 000000000000..7bd15f5a5189 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserForgottenPasswordRequestedWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Forgotten Password Requested")] +public class UserForgottenPasswordRequestedWebhookEvent : WebhookEventBase +{ + public UserForgottenPasswordRequestedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userForgottenPasswordRequested"; +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserGroupDeletedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserGroupDeletedWebhookEvent.cs new file mode 100644 index 000000000000..c05bacb3779e --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserGroupDeletedWebhookEvent.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Group Deleted")] +public class UserGroupDeletedWebhookEvent : WebhookEventBase +{ + public UserGroupDeletedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userGroupDeleted"; + + public override object? ConvertNotificationToRequestPayload(UserGroupDeletedNotification notification) => notification.DeletedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserGroupSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserGroupSavedWebhookEvent.cs new file mode 100644 index 000000000000..0bfe438a7b75 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserGroupSavedWebhookEvent.cs @@ -0,0 +1,24 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Group Saved")] +public class UserGroupSavedWebhookEvent : WebhookEventBase +{ + public UserGroupSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userGroupSaved"; + + public override object? ConvertNotificationToRequestPayload(UserGroupSavedNotification notification) => notification.SavedEntities; +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserLockedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserLockedWebhookEvent.cs new file mode 100644 index 000000000000..eb3106687f40 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserLockedWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Locked")] +public class UserLockedWebhookEvent : WebhookEventBase +{ + public UserLockedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userLocked"; +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserLoginFailedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserLoginFailedWebhookEvent.cs new file mode 100644 index 000000000000..e6957d39dcd7 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserLoginFailedWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Login Failed")] +public class UserLoginFailedWebhookEvent : WebhookEventBase +{ + public UserLoginFailedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userLoginFailed"; +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserLoginRequiresVerificationWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserLoginRequiresVerificationWebhookEvent.cs new file mode 100644 index 000000000000..a64282715024 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserLoginRequiresVerificationWebhookEvent.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Login Requires Verification")] +public class UserLoginRequiresVerificationWebhookEvent : WebhookEventBase +{ + public UserLoginRequiresVerificationWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userLoginRequiresVerification"; + +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserLoginSuccessWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserLoginSuccessWebhookEvent.cs new file mode 100644 index 000000000000..58b98d8e0775 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserLoginSuccessWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Login Success")] +public class UserLoginSuccessWebhookEvent : WebhookEventBase +{ + public UserLoginSuccessWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userLoginSuccess"; +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserLogoutSuccessWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserLogoutSuccessWebhookEvent.cs new file mode 100644 index 000000000000..dc0f8d7bb232 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserLogoutSuccessWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Logout Success")] +public class UserLogoutSuccessWebhookEvent : WebhookEventBase +{ + public UserLogoutSuccessWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userLogoutSuccess"; +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserPasswordChangedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserPasswordChangedWebhookEvent.cs new file mode 100644 index 000000000000..99c654aba383 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserPasswordChangedWebhookEvent.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Password Changed")] +public class UserPasswordChangedWebhookEvent : WebhookEventBase +{ + public UserPasswordChangedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userPasswordChanged"; + +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserPasswordResetWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserPasswordResetWebhookEvent.cs new file mode 100644 index 000000000000..368116df0bcd --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserPasswordResetWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Password Reset")] +public class UserPasswordResetWebhookEvent : WebhookEventBase +{ + public UserPasswordResetWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userPasswordReset"; +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserSavedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserSavedWebhookEvent.cs new file mode 100644 index 000000000000..ee65e9b2eb06 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserSavedWebhookEvent.cs @@ -0,0 +1,39 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Saved")] +public class UserSavedWebhookEvent : WebhookEventBase +{ + public UserSavedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userSaved"; + + public override object? ConvertNotificationToRequestPayload(UserSavedNotification notification) + { + // TODO: Map more stuff here + var result = notification.SavedEntities.Select(entity => new + { + entity.Id, + entity.Key, + entity.Name, + entity.Language, + entity.Email, + entity.Username, + entity.FailedPasswordAttempts + }); + + return result; + } +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserTwoFactorRequestedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserTwoFactorRequestedWebhookEvent.cs new file mode 100644 index 000000000000..afcac294ca82 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserTwoFactorRequestedWebhookEvent.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Two Factor Requested")] +public class UserTwoFactorRequestedWebhookEvent : WebhookEventBase +{ + public UserTwoFactorRequestedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userTwoFactorRequested"; + +} diff --git a/src/Umbraco.Core/Webhooks/Events/User/UserUnlockedWebhookEvent.cs b/src/Umbraco.Core/Webhooks/Events/User/UserUnlockedWebhookEvent.cs new file mode 100644 index 000000000000..a6aea6219695 --- /dev/null +++ b/src/Umbraco.Core/Webhooks/Events/User/UserUnlockedWebhookEvent.cs @@ -0,0 +1,22 @@ +using Microsoft.Extensions.Options; +using Umbraco.Cms.Core.Configuration.Models; +using Umbraco.Cms.Core.Notifications; +using Umbraco.Cms.Core.Services; +using Umbraco.Cms.Core.Sync; + +namespace Umbraco.Cms.Core.Webhooks.Events.User; + +[WebhookEvent("User Unlocked")] +public class UserUnlockedWebhookEvent : WebhookEventBase +{ + public UserUnlockedWebhookEvent( + IWebhookFiringService webhookFiringService, + IWebhookService webHookService, + IOptionsMonitor webhookSettings, + IServerRoleAccessor serverRoleAccessor) + : base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor) + { + } + + public override string Alias => "userUnlocked"; +} diff --git a/src/Umbraco.Core/Webhooks/WebhookEventBase.cs b/src/Umbraco.Core/Webhooks/WebhookEventBase.cs index 5d4ee69d3b8d..138ebc56fdc3 100644 --- a/src/Umbraco.Core/Webhooks/WebhookEventBase.cs +++ b/src/Umbraco.Core/Webhooks/WebhookEventBase.cs @@ -62,7 +62,7 @@ public virtual async Task ProcessWebhooks(TNotification notification, IEnumerabl continue; } - await WebhookFiringService.FireAsync(webhook, Alias, notification, cancellationToken); + await WebhookFiringService.FireAsync(webhook, Alias, ConvertNotificationToRequestPayload(notification), cancellationToken); } } @@ -95,4 +95,14 @@ public async Task HandleAsync(TNotification notification, CancellationToken canc await ProcessWebhooks(notification, webhooks, cancellationToken); } + + /// + /// Use this method if you wish to change the shape of the object to be serialised + /// for the JSON webhook payload. + /// For example excluding sensitive data + /// + /// + /// + public virtual object? ConvertNotificationToRequestPayload(TNotification notification) + => notification; } diff --git a/src/Umbraco.Core/Webhooks/WebhookEventCollectionBuilder.cs b/src/Umbraco.Core/Webhooks/WebhookEventCollectionBuilder.cs index e0eeb186e856..9ebc7ee13fb1 100644 --- a/src/Umbraco.Core/Webhooks/WebhookEventCollectionBuilder.cs +++ b/src/Umbraco.Core/Webhooks/WebhookEventCollectionBuilder.cs @@ -2,35 +2,43 @@ using Umbraco.Cms.Core.Composing; using Umbraco.Cms.Core.Events; using Umbraco.Cms.Core.Notifications; -using Umbraco.Cms.Core.Webhooks.Events; +using Umbraco.Cms.Core.Webhooks.Events.Content; +using Umbraco.Cms.Core.Webhooks.Events.DataType; +using Umbraco.Cms.Core.Webhooks.Events.Dictionary; +using Umbraco.Cms.Core.Webhooks.Events.Domain; +using Umbraco.Cms.Core.Webhooks.Events.Language; +using Umbraco.Cms.Core.Webhooks.Events.Media; +using Umbraco.Cms.Core.Webhooks.Events.MediaType; +using Umbraco.Cms.Core.Webhooks.Events.Member; +using Umbraco.Cms.Core.Webhooks.Events.MemberType; +using Umbraco.Cms.Core.Webhooks.Events.Package; +using Umbraco.Cms.Core.Webhooks.Events.PublicAccess; +using Umbraco.Cms.Core.Webhooks.Events.Relation; +using Umbraco.Cms.Core.Webhooks.Events.RelationType; +using Umbraco.Cms.Core.Webhooks.Events.Script; +using Umbraco.Cms.Core.Webhooks.Events.Stylesheet; +using Umbraco.Cms.Core.Webhooks.Events.Template; +using Umbraco.Cms.Core.Webhooks.Events.User; using Umbraco.Extensions; namespace Umbraco.Cms.Core.Webhooks; -public class WebhookEventCollectionBuilder : OrderedCollectionBuilderBase +public class WebhookEventCollectionBuilder : OrderedCollectionBuilderBase { protected override WebhookEventCollectionBuilder This => this; public override void RegisterWith(IServiceCollection services) { // register the collection - services.Add(new ServiceDescriptor(typeof(WebhookEventCollection), CreateCollection, ServiceLifetime.Singleton)); + services.Add(new ServiceDescriptor(typeof(WebhookEventCollection), CreateCollection, + ServiceLifetime.Singleton)); // register the types RegisterTypes(services); base.RegisterWith(services); } - public WebhookEventCollectionBuilder AddCoreWebhooks() - { - Append(); - Append(); - Append(); - Append(); - Append(); - return this; - } - private void RegisterTypes(IServiceCollection services) { Type[] types = GetRegisteringTypes(GetTypes()).ToArray(); @@ -68,7 +76,8 @@ private void RegisterTypes(IServiceCollection services) { Type[] genericArguments = handlerType.BaseType!.GetGenericArguments(); - Type? notificationType = genericArguments.FirstOrDefault(arg => typeof(INotification).IsAssignableFrom(arg)); + Type? notificationType = + genericArguments.FirstOrDefault(arg => typeof(INotification).IsAssignableFrom(arg)); if (notificationType is not null) { @@ -78,4 +87,187 @@ private void RegisterTypes(IServiceCollection services) return null; } + + public WebhookEventCollectionBuilder AddAllAvailableWebhooks() => + this.AddContentWebhooks() + .AddDataTypeWebhooks() + .AddDictionaryWebhooks() + .AddDomainWebhooks() + .AddLanguageWebhooks() + .AddMediaWebhooks() + .AddMemberWebhooks() + .AddMemberTypeWebhooks() + .AddPackageWebhooks() + .AddPublicAccessWebhooks() + .AddRelationWebhooks() + .AddScriptWebhooks() + .AddStylesheetWebhooks() + .AddTemplateWebhooks() + .AddUserWebhooks(); + + public WebhookEventCollectionBuilder AddContentWebhooks() + { + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddCoreWebhooks() + { + Append(); + Append(); + Append(); + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddDataTypeWebhooks() + { + Append(); + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddDictionaryWebhooks() + { + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddDomainWebhooks() + { + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddLanguageWebhooks() + { + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddMediaWebhooks() + { + // Even though these two are in the AddCoreWebhooks() + // The job of the CollectionBuilder should be removing duplicates + // Would allow someone to use .AddCoreWebhooks().AddMediaWebhooks() + // Or if they explicitly they could skip over CoreWebHooks and just add this perhaps + Append(); + Append(); + + Append(); + Append(); + Append(); + + Append(); + Append(); + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddMemberWebhooks() + { + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddMemberTypeWebhooks() + { + Append(); + Append(); + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddPackageWebhooks() + { + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddPublicAccessWebhooks() + { + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddRelationWebhooks() + { + Append(); + Append(); + + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddScriptWebhooks() + { + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddStylesheetWebhooks() + { + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddTemplateWebhooks() + { + Append(); + Append(); + + Append(); + Append(); + return this; + } + + public WebhookEventCollectionBuilder AddUserWebhooks() + { + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + Append(); + return this; + } } diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/eventpicker/eventpicker.html b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/eventpicker/eventpicker.html index e65a5f767f41..e87674791c36 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/eventpicker/eventpicker.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/eventpicker/eventpicker.html @@ -2,29 +2,55 @@ - + + + - - +
+ + +
- - -
    -
  • -
    - -
    -
  • -
+ + +
+
    +
  • +
    + +
    +
  • +
+
+ + + No events were found. +