V13: Webhook all the things (#15161)

This commit is contained in:
Warren Buckley
2023-11-30 14:41:45 +00:00
committed by GitHub
parent 34d6695c89
commit d088ed8bf6
79 changed files with 2234 additions and 58 deletions

View File

@@ -6,6 +6,57 @@ public static partial class Constants
{
public static class Aliases
{
/// <summary>
/// Webhook event alias for content versions deleted
/// </summary>
public const string ContentDeletedVersions = "Umbraco.ContentDeletedVersions";
/// <summary>
/// Webhook event alias for content blueprint saved
/// </summary>
public const string ContentSavedBlueprint = "Umbraco.ContentSavedBlueprint";
/// <summary>
/// Webhook event alias for content blueprint deleted
/// </summary>
public const string ContentDeletedBlueprint = "Umbraco.ContentDeletedBlueprint";
/// <summary>
/// Webhook event alias for content moved into the recycle bin.
/// </summary>
public const string ContentMovedToRecycleBin = "Umbraco.ContentMovedToRecycleBin";
/// <summary>
/// Webhook event alias for content sorted.
/// </summary>
public const string ContentSorted = "Umbraco.ContentSorted";
/// <summary>
/// Webhook event alias for content moved.
/// </summary>
public const string ContentMoved = "Umbraco.ContentMoved";
/// <summary>
/// Webhook event alias for content copied.
/// </summary>
public const string ContentCopied = "Umbraco.ContentCopied";
/// <summary>
/// Webhook event alias for content emptied recycle bin.
/// </summary>
public const string ContentEmptiedRecycleBin = "Umbraco.ContentEmptiedRecycleBin";
/// <summary>
/// Webhook event alias for content rolled back.
/// </summary>
public const string ContentRolledBack = "Umbraco.ContentRolledBack";
/// <summary>
/// Webhook event alias for content saved.
/// </summary>
public const string ContentSaved = "Umbraco.ContentSaved";
/// <summary>
/// Webhook event alias for content publish.
/// </summary>

View File

@@ -1941,6 +1941,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="createHeader">Create header</key>
<key alias="logs">Logs</key>
<key alias="noHeaders">No webhook headers have been added</key>
<key alias="noEventsFound">No events were found.</key>
</area>
<area alias="languages">
<key alias="addLanguage">Add language</key>

View File

@@ -2023,6 +2023,7 @@ To manage your website, simply open the Umbraco backoffice and start adding cont
<key alias="createHeader">Create header</key>
<key alias="logs">Logs</key>
<key alias="noHeaders">No webhook headers have been added</key>
<key alias="noEventsFound">No events were found.</key>
</area>
<area alias="languages">
<key alias="addLanguage">Add language</key>

View File

@@ -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<ContentCopiedNotification>
{
public ContentCopiedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> 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
};
}
}

View File

@@ -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<ContentDeletedBlueprintNotification, IContent>
{
public ContentDeletedBlueprintWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(
webhookFiringService,
webhookService,
webhookSettings,
serverRoleAccessor)
{
}
public override string Alias => Constants.WebhookEvents.Aliases.ContentDeletedBlueprint;
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentDeletedBlueprintNotification notification) =>
notification.DeletedBlueprints;
protected override object ConvertEntityToRequestPayload(IContent entity) => entity;
}

View File

@@ -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<ContentDeletedVersionsNotification>
{
public ContentDeletedVersionsWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> 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
};
}
}

View File

@@ -5,12 +5,12 @@ using Umbraco.Cms.Core.Notifications;
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<ContentDeletedNotification, IContent>
[WebhookEvent("Content Deleted", Constants.WebhookEvents.Types.Content)]
public class ContentDeletedWebhookEvent : WebhookEventContentBase<ContentDeletedNotification, IContent>
{
public ContentDeleteWebhookEvent(
public ContentDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> webhookSettings,

View File

@@ -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<ContentEmptiedRecycleBinNotification, IContent>
{
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IApiContentBuilder _apiContentBuilder;
public ContentEmptiedRecycleBinWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> 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<IContent> GetEntitiesFromNotification(ContentEmptiedRecycleBinNotification notification) =>
notification.DeletedEntities;
protected override object? ConvertEntityToRequestPayload(IContent entity) => entity;
}

View File

@@ -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<ContentMovedToRecycleBinNotification>
{
public ContentMovedToRecycleBinWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(
webhookFiringService,
webhookService,
webhookSettings,
serverRoleAccessor)
{
}
public override string Alias => Constants.WebhookEvents.Aliases.ContentMovedToRecycleBin;
public override object? ConvertNotificationToRequestPayload(ContentMovedToRecycleBinNotification notification)
=> notification.MoveInfoCollection;
}

View File

@@ -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<ContentMovedNotification>
{
public ContentMovedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(
webhookFiringService,
webhookService,
webhookSettings,
serverRoleAccessor)
{
}
public override string Alias => Constants.WebhookEvents.Aliases.ContentMoved;
public override object? ConvertNotificationToRequestPayload(ContentMovedNotification notification)
=> notification.MoveInfoCollection;
}

View File

@@ -8,15 +8,15 @@ using Umbraco.Cms.Core.PublishedCache;
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<ContentPublishedNotification, IContent>
[WebhookEvent("Content Published", Constants.WebhookEvents.Types.Content)]
public class ContentPublishedWebhookEvent : WebhookEventContentBase<ContentPublishedNotification, IContent>
{
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IApiContentBuilder _apiContentBuilder;
public ContentPublishWebhookEvent(
public ContentPublishedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> webhookSettings,

View File

@@ -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<ContentRolledBackNotification, IContent>
{
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IApiContentBuilder _apiContentBuilder;
public ContentRolledBackWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> 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<IContent> GetEntitiesFromNotification(ContentRolledBackNotification notification) =>
new List<IContent> { 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);
}
}

View File

@@ -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<ContentSavedBlueprintNotification, IContent>
{
public ContentSavedBlueprintWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(
webhookFiringService,
webhookService,
webhookSettings,
serverRoleAccessor)
{
}
public override string Alias => Constants.WebhookEvents.Aliases.ContentSavedBlueprint;
protected override IEnumerable<IContent>
GetEntitiesFromNotification(ContentSavedBlueprintNotification notification)
=> new List<IContent> { notification.SavedBlueprint };
protected override object ConvertEntityToRequestPayload(IContent entity) => entity;
}

View File

@@ -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<ContentSavedNotification, IContent>
{
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IApiContentBuilder _apiContentBuilder;
public ContentSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> 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<IContent> 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);
}
}

View File

@@ -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<ContentSortedNotification>
{
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IApiContentBuilder _apiContentBuilder;
public ContentSortedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> 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<object?>();
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;
}
}

View File

@@ -5,12 +5,12 @@ using Umbraco.Cms.Core.Notifications;
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<ContentUnpublishedNotification, IContent>
[WebhookEvent("Content Unpublished", Constants.WebhookEvents.Types.Content)]
public class ContentUnpublishedWebhookEvent : WebhookEventContentBase<ContentUnpublishedNotification, IContent>
{
public ContentUnpublishWebhookEvent(
public ContentUnpublishedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> webhookSettings,

View File

@@ -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<DataTypeSavedNotification>
{
public DataTypeDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "dataTypeDeleted";
public override object? ConvertNotificationToRequestPayload(DataTypeSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<DataTypeMovedNotification>
{
public DataTypeMovedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "dataTypeMoved";
public override object? ConvertNotificationToRequestPayload(DataTypeMovedNotification notification)
=> notification.MoveInfoCollection;
}

View File

@@ -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<DataTypeSavedNotification>
{
public DataTypeSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "dataTypeSaved";
public override object? ConvertNotificationToRequestPayload(DataTypeSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<DictionaryItemDeletedNotification>
{
public DictionaryItemDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "dictionaryItemDeleted";
public override object? ConvertNotificationToRequestPayload(DictionaryItemDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<DictionaryItemSavedNotification>
{
public DictionaryItemSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "dictionaryItemSaved";
public override object? ConvertNotificationToRequestPayload(DictionaryItemSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<DomainDeletedNotification>
{
public DomainDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "domainDeleted";
public override object? ConvertNotificationToRequestPayload(DomainDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<DomainSavedNotification>
{
public DomainSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "domainSaved";
public override object? ConvertNotificationToRequestPayload(DomainSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<LanguageDeletedNotification>
{
public LanguageDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "languageDeleted";
public override object? ConvertNotificationToRequestPayload(LanguageDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<LanguageSavedNotification>
{
public LanguageSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "languageSaved";
public override object? ConvertNotificationToRequestPayload(LanguageSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -5,12 +5,12 @@ using Umbraco.Cms.Core.Notifications;
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<MediaDeletedNotification, IMedia>
[WebhookEvent("Media Deleted", Constants.WebhookEvents.Types.Media)]
public class MediaDeletedWebhookEvent : WebhookEventContentBase<MediaDeletedNotification, IMedia>
{
public MediaDeleteWebhookEvent(
public MediaDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> webhookSettings,

View File

@@ -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<MediaEmptiedRecycleBinNotification, IMedia>
{
public MediaEmptiedRecycleBinWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(
webhookFiringService,
webHookService,
webhookSettings,
serverRoleAccessor)
{
}
public override string Alias => "mediaEmptiedRecycleBin";
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaEmptiedRecycleBinNotification notification) => notification.DeletedEntities;
protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key };
}

View File

@@ -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<MediaMovedToRecycleBinNotification, IMedia>
{
public MediaMovedToRecycleBinWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(
webhookFiringService,
webHookService,
webhookSettings,
serverRoleAccessor)
{
}
public override string Alias => "mediaMovedToRecycleBin";
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaMovedToRecycleBinNotification notification) => notification.MoveInfoCollection.Select(x => x.Entity);
protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key };
}

View File

@@ -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<MediaMovedNotification, IMedia>
{
public MediaMovedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(
webhookFiringService,
webHookService,
webhookSettings,
serverRoleAccessor)
{
}
public override string Alias => "mediaMoved";
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaMovedNotification notification) => notification.MoveInfoCollection.Select(x => x.Entity);
protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key };
}

View File

@@ -8,15 +8,15 @@ using Umbraco.Cms.Core.PublishedCache;
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<MediaSavedNotification, IMedia>
[WebhookEvent("Media Saved", Constants.WebhookEvents.Types.Media)]
public class MediaSavedWebhookEvent : WebhookEventContentBase<MediaSavedNotification, IMedia>
{
private readonly IPublishedSnapshotAccessor _publishedSnapshotAccessor;
private readonly IApiMediaBuilder _apiMediaBuilder;
public MediaSaveWebhookEvent(
public MediaSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webhookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
@@ -29,8 +29,8 @@ public class MediaSaveWebhookEvent : WebhookEventContentBase<MediaSavedNotificat
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 class MediaSaveWebhookEvent : WebhookEventContentBase<MediaSavedNotificat
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);
}
}

View File

@@ -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<MediaTypeChangedNotification>
{
public MediaTypeChangedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "mediaTypeChanged";
public override object? ConvertNotificationToRequestPayload(MediaTypeChangedNotification notification)
=> notification.Changes;
}

View File

@@ -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<MediaTypeDeletedNotification>
{
public MediaTypeDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "mediaTypeDeleted";
public override object? ConvertNotificationToRequestPayload(MediaTypeDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<MediaTypeMovedNotification>
{
public MediaTypeMovedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "mediaTypeMoved";
public override object? ConvertNotificationToRequestPayload(MediaTypeMovedNotification notification)
=> notification.MoveInfoCollection;
}

View File

@@ -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<MediaTypeSavedNotification>
{
public MediaTypeSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "mediaTypeSaved";
public override object? ConvertNotificationToRequestPayload(MediaTypeSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<AssignedMemberRolesNotification>
{
public AssignedMemberRolesWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "assignedMemberRoles";
}

View File

@@ -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<ExportedMemberNotification>
{
public ExportedMemberWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> 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
};
}
}

View File

@@ -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<MemberDeletedNotification>
{
public MemberDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> 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;
}
}

View File

@@ -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<MemberGroupDeletedNotification>
{
public MemberGroupDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "memberGroupDeleted";
public override object? ConvertNotificationToRequestPayload(MemberGroupDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<MemberGroupSavedNotification>
{
public MemberGroupSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "memberGroupSaved";
public override object? ConvertNotificationToRequestPayload(MemberGroupSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<MemberSavedNotification>
{
public MemberSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> 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;
}
}

View File

@@ -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<RemovedMemberRolesNotification>
{
public RemovedMemberRolesWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "removedMemberRoles";
}

View File

@@ -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<MemberTypeChangedNotification>
{
public MemberTypeChangedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "memberTypeChanged";
public override object? ConvertNotificationToRequestPayload(MemberTypeChangedNotification notification)
=> notification.Changes;
}

View File

@@ -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<MemberTypeDeletedNotification>
{
public MemberTypeDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "memberTypeDeleted";
public override object? ConvertNotificationToRequestPayload(MemberTypeDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<MemberTypeMovedNotification>
{
public MemberTypeMovedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "memberTypeMoved";
public override object? ConvertNotificationToRequestPayload(MemberTypeMovedNotification notification)
=> notification.MoveInfoCollection;
}

View File

@@ -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<MemberTypeSavedNotification>
{
public MemberTypeSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "memberTypeSaved";
public override object? ConvertNotificationToRequestPayload(MemberTypeSavedNotification notification) =>
notification.SavedEntities;
}

View File

@@ -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<ImportedPackageNotification>
{
public ImportedPackageWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "packageImported";
}

View File

@@ -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<PublicAccessEntryDeletedNotification>
{
public PublicAccessEntryDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "publicAccessEntryDeleted";
public override object? ConvertNotificationToRequestPayload(PublicAccessEntryDeletedNotification notification) => notification.DeletedEntities;
}

View File

@@ -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<PublicAccessEntrySavedNotification>
{
public PublicAccessEntrySavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "publicAccessEntrySaved";
public override object? ConvertNotificationToRequestPayload(PublicAccessEntrySavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<RelationDeletedNotification>
{
public RelationDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "relationDeleted";
public override object? ConvertNotificationToRequestPayload(RelationDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<RelationSavedNotification>
{
public RelationSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "relationSaved";
public override object? ConvertNotificationToRequestPayload(RelationSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<RelationTypeDeletedNotification>
{
public RelationTypeDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "relationTypeDeleted";
public override object? ConvertNotificationToRequestPayload(RelationTypeDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<RelationTypeSavedNotification>
{
public RelationTypeSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "relationTypeSaved";
public override object? ConvertNotificationToRequestPayload(RelationTypeSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<ScriptDeletedNotification>
{
public ScriptDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "scriptDeleted";
public override object? ConvertNotificationToRequestPayload(ScriptDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<ScriptDeletedNotification>
{
public ScriptSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "scriptSaved";
public override object? ConvertNotificationToRequestPayload(ScriptDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<StylesheetDeletedNotification>
{
public StylesheetDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "stylesheetDeleted";
public override object? ConvertNotificationToRequestPayload(StylesheetDeletedNotification notification) =>
notification.DeletedEntities;
}

View File

@@ -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<StylesheetSavedNotification>
{
public StylesheetSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "stylesheetSaved";
public override object? ConvertNotificationToRequestPayload(StylesheetSavedNotification notification)
=> notification.SavedEntities;
}

View File

@@ -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<PartialViewDeletedNotification>
{
public PartialViewDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "partialViewDeleted";
public override object? ConvertNotificationToRequestPayload(PartialViewDeletedNotification notification)
=> notification.DeletedEntities;
}

View File

@@ -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<PartialViewSavedNotification>
{
public PartialViewSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "partialViewSaved";
public override object? ConvertNotificationToRequestPayload(PartialViewSavedNotification notification) =>
notification.SavedEntities;
}

View File

@@ -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<TemplateDeletedNotification>
{
public TemplateDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "templateDeleted";
public override object? ConvertNotificationToRequestPayload(TemplateDeletedNotification notification) =>
notification.DeletedEntities;
}

View File

@@ -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<TemplateSavedNotification>
{
public TemplateSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> 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
};
}
}

View File

@@ -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<AssignedUserGroupPermissionsNotification>
{
public AssignedUserGroupPermissionsWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "assignedUserGroupPermissions";
public override object? ConvertNotificationToRequestPayload(AssignedUserGroupPermissionsNotification notification)
=> notification.EntityPermissions;
}

View File

@@ -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<UserDeletedNotification>
{
public UserDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> 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;
}
}

View File

@@ -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<UserForgotPasswordRequestedNotification>
{
public UserForgotPasswordRequestedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userForgotPasswordRequested";
}

View File

@@ -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<UserForgotPasswordRequestedNotification>
{
public UserForgottenPasswordRequestedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userForgottenPasswordRequested";
}

View File

@@ -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<UserGroupDeletedNotification>
{
public UserGroupDeletedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userGroupDeleted";
public override object? ConvertNotificationToRequestPayload(UserGroupDeletedNotification notification) => notification.DeletedEntities;
}

View File

@@ -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<UserGroupSavedNotification>
{
public UserGroupSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userGroupSaved";
public override object? ConvertNotificationToRequestPayload(UserGroupSavedNotification notification) => notification.SavedEntities;
}

View File

@@ -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<UserLockedNotification>
{
public UserLockedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userLocked";
}

View File

@@ -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<UserLoginFailedNotification>
{
public UserLoginFailedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userLoginFailed";
}

View File

@@ -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<UserLoginRequiresVerificationNotification>
{
public UserLoginRequiresVerificationWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userLoginRequiresVerification";
}

View File

@@ -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<UserLoginSuccessNotification>
{
public UserLoginSuccessWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userLoginSuccess";
}

View File

@@ -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<UserLogoutSuccessNotification>
{
public UserLogoutSuccessWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userLogoutSuccess";
}

View File

@@ -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<UserPasswordChangedNotification>
{
public UserPasswordChangedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userPasswordChanged";
}

View File

@@ -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<UserPasswordResetNotification>
{
public UserPasswordResetWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userPasswordReset";
}

View File

@@ -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<UserSavedNotification>
{
public UserSavedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> 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;
}
}

View File

@@ -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<UserTwoFactorRequestedNotification>
{
public UserTwoFactorRequestedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userTwoFactorRequested";
}

View File

@@ -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<UserUnlockedNotification>
{
public UserUnlockedWebhookEvent(
IWebhookFiringService webhookFiringService,
IWebhookService webHookService,
IOptionsMonitor<WebhookSettings> webhookSettings,
IServerRoleAccessor serverRoleAccessor)
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
{
}
public override string Alias => "userUnlocked";
}

View File

@@ -62,7 +62,7 @@ public abstract class WebhookEventBase<TNotification> : IWebhookEvent, INotifica
continue;
}
await WebhookFiringService.FireAsync(webhook, Alias, notification, cancellationToken);
await WebhookFiringService.FireAsync(webhook, Alias, ConvertNotificationToRequestPayload(notification), cancellationToken);
}
}
@@ -95,4 +95,14 @@ public abstract class WebhookEventBase<TNotification> : IWebhookEvent, INotifica
await ProcessWebhooks(notification, webhooks, cancellationToken);
}
/// <summary>
/// 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
/// </summary>
/// <param name="notification"></param>
/// <returns></returns>
public virtual object? ConvertNotificationToRequestPayload(TNotification notification)
=> notification;
}

View File

@@ -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<WebhookEventCollectionBuilder, WebhookEventCollection, IWebhookEvent>
public class WebhookEventCollectionBuilder : OrderedCollectionBuilderBase<WebhookEventCollectionBuilder,
WebhookEventCollection, IWebhookEvent>
{
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<ContentDeleteWebhookEvent>();
Append<ContentPublishWebhookEvent>();
Append<ContentUnpublishWebhookEvent>();
Append<MediaDeleteWebhookEvent>();
Append<MediaSaveWebhookEvent>();
return this;
}
private void RegisterTypes(IServiceCollection services)
{
Type[] types = GetRegisteringTypes(GetTypes()).ToArray();
@@ -68,7 +76,8 @@ public class WebhookEventCollectionBuilder : OrderedCollectionBuilderBase<Webhoo
{
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 @@ public class WebhookEventCollectionBuilder : OrderedCollectionBuilderBase<Webhoo
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<ContentCopiedWebhookEvent>();
Append<ContentDeletedBlueprintWebhookEvent>();
Append<ContentDeletedVersionsWebhookEvent>();
Append<ContentDeletedWebhookEvent>();
Append<ContentEmptiedRecycleBinWebhookEvent>();
Append<ContentMovedToRecycleBinWebhookEvent>();
Append<ContentMovedWebhookEvent>();
Append<ContentPublishedWebhookEvent>();
Append<ContentRolledBackWebhookEvent>();
Append<ContentSavedBlueprintWebhookEvent>();
Append<ContentSavedWebhookEvent>();
Append<ContentSortedWebhookEvent>();
Append<ContentUnpublishedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddCoreWebhooks()
{
Append<ContentDeletedWebhookEvent>();
Append<ContentPublishedWebhookEvent>();
Append<ContentUnpublishedWebhookEvent>();
Append<MediaDeletedWebhookEvent>();
Append<MediaSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddDataTypeWebhooks()
{
Append<DataTypeDeletedWebhookEvent>();
Append<DataTypeMovedWebhookEvent>();
Append<DataTypeSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddDictionaryWebhooks()
{
Append<DictionaryItemDeletedWebhookEvent>();
Append<DictionaryItemSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddDomainWebhooks()
{
Append<DomainDeletedWebhookEvent>();
Append<DomainSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddLanguageWebhooks()
{
Append<LanguageDeletedWebhookEvent>();
Append<LanguageSavedWebhookEvent>();
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<MediaDeletedWebhookEvent>();
Append<MediaSavedWebhookEvent>();
Append<MediaEmptiedRecycleBinWebhookEvent>();
Append<MediaMovedWebhookEvent>();
Append<MediaMovedToRecycleBinWebhookEvent>();
Append<MediaTypeChangedWebhookEvent>();
Append<MediaTypeDeletedWebhookEvent>();
Append<MediaTypeMovedWebhookEvent>();
Append<MediaTypeSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddMemberWebhooks()
{
Append<AssignedMemberRolesWebhookEvent>();
Append<ExportedMemberWebhookEvent>();
Append<MemberDeletedWebhookEvent>();
Append<MemberGroupDeletedWebhookEvent>();
Append<MemberGroupSavedWebhookEvent>();
Append<MemberSavedWebhookEvent>();
Append<RemovedMemberRolesWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddMemberTypeWebhooks()
{
Append<MemberTypeChangedWebhookEvent>();
Append<MemberTypeDeletedWebhookEvent>();
Append<MemberTypeMovedWebhookEvent>();
Append<MemberTypeSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddPackageWebhooks()
{
Append<ImportedPackageWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddPublicAccessWebhooks()
{
Append<PublicAccessEntryDeletedWebhookEvent>();
Append<PublicAccessEntrySavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddRelationWebhooks()
{
Append<RelationDeletedWebhookEvent>();
Append<RelationSavedWebhookEvent>();
Append<RelationTypeDeletedWebhookEvent>();
Append<RelationTypeSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddScriptWebhooks()
{
Append<ScriptDeletedWebhookEvent>();
Append<ScriptSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddStylesheetWebhooks()
{
Append<StylesheetDeletedWebhookEvent>();
Append<StylesheetSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddTemplateWebhooks()
{
Append<PartialViewDeletedWebhookEvent>();
Append<PartialViewSavedWebhookEvent>();
Append<TemplateDeletedWebhookEvent>();
Append<TemplateSavedWebhookEvent>();
return this;
}
public WebhookEventCollectionBuilder AddUserWebhooks()
{
Append<AssignedUserGroupPermissionsWebhookEvent>();
Append<UserDeletedWebhookEvent>();
Append<UserForgotPasswordRequestedWebhookEvent>();
Append<UserForgottenPasswordRequestedWebhookEvent>();
Append<UserGroupDeletedWebhookEvent>();
Append<UserGroupSavedWebhookEvent>();
Append<UserLockedWebhookEvent>();
Append<UserLoginFailedWebhookEvent>();
Append<UserLoginRequiresVerificationWebhookEvent>();
Append<UserLoginSuccessWebhookEvent>();
Append<UserLogoutSuccessWebhookEvent>();
Append<UserPasswordChangedWebhookEvent>();
Append<UserPasswordResetWebhookEvent>();
Append<UserSavedWebhookEvent>();
Append<UserTwoFactorRequestedWebhookEvent>();
Append<UserUnlockedWebhookEvent>();
return this;
}
}

View File

@@ -2,29 +2,55 @@
<umb-editor-view>
<umb-editor-header name="model.title" name-locked="true" hide-alias="true" hide-icon="true" hide-description="true">
<umb-editor-header
name="model.title"
name-locked="true"
hide-alias="true"
hide-icon="true"
hide-description="true">
</umb-editor-header>
<umb-editor-container>
<umb-load-indicator ng-if="vm.loading">
</umb-load-indicator>
<umb-box ng-if="!vm.loading">
<umb-box>
<umb-box-content>
<ul class="umb-tree">
<li class="umb-tree-item" ng-repeat="event in vm.events">
<div class="umb-tree-item__inner" style="padding: 5px 10px;">
<button type="button" class="btn-reset text-left flex-auto"
ng-class="{ 'umb-tree-node-checked': event.selected }" ng-click="vm.selectEvent(event)">
<umb-icon icon="{{event.selected ? 'icon-check' : 'icon-flag'}}" class="icon umb-tree-icon"
ng-class="{ 'color-green': event.selected }">
</umb-icon>
<span>{{ event.eventName }}</span>
</button>
</div>
</li>
</ul>
<div class="umb-control-group">
<umb-search-filter
input-id="event-search"
model="vm.filter.searchTerm"
label-key="placeholders_search"
text="Type to search"
css-class="w-100"
auto-focus="true">
</umb-search-filter>
</div>
<umb-load-indicator ng-if="vm.loading"></umb-load-indicator>
<div ng-show="vm.loading === false && filtered.length > 0">
<ul class="umb-tree">
<li class="umb-tree-item" ng-repeat="event in filtered = (vm.events | filter: { 'eventName': vm.filter.searchTerm } | orderBy: '+eventName')">
<div class="umb-tree-item__inner" style="padding: 5px 10px;">
<button type="button"
class="btn-reset text-left flex-auto"
ng-class="{ 'umb-tree-node-checked': event.selected }"
ng-click="vm.selectEvent(event)">
<umb-icon icon="{{ event.selected ? 'icon-check' : 'icon-flag'}}"
class="icon umb-tree-icon"
ng-class="{ 'color-green': event.selected }">
</umb-icon>
<span>{{ event.eventName }}</span>
</button>
</div>
</li>
</ul>
</div>
<umb-empty-state
ng-if="filtered.length === 0"
position="center">
<localize key="webhooks_noEventsFound">No events were found.</localize>
</umb-empty-state>
</umb-box-content>
</umb-box>
</umb-editor-container>