Normalize webhook payloads (#19110)
Co-authored-by: Andy Butland <abutland73@gmail.com> Co-authored-by: Kenn Jacobsen <kja@umbraco.dk>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using Umbraco.Cms.Core.Webhooks;
|
||||
|
||||
namespace Umbraco.Cms.Core.Configuration.Models;
|
||||
|
||||
@@ -10,6 +11,7 @@ public class WebhookSettings
|
||||
internal const string StaticPeriod = "00:00:10";
|
||||
private const bool StaticEnableLoggingCleanup = true;
|
||||
private const int StaticKeepLogsForDays = 30;
|
||||
private const WebhookPayloadType StaticPayloadType = Constants.Webhooks.DefaultPayloadType;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -63,4 +65,16 @@ public class WebhookSettings
|
||||
/// </remarks>
|
||||
[DefaultValue(StaticKeepLogsForDays)]
|
||||
public int KeepLogsForDays { get; set; } = StaticKeepLogsForDays;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating the type of payload used for sending webhooks
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// By default, Legacy payloads are used see <see cref="WebhookPayloadType"/> for more info.
|
||||
/// This default will change to minimal starting from v17.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
[DefaultValue(StaticPayloadType)]
|
||||
public WebhookPayloadType PayloadType { get; set; } = StaticPayloadType;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public static partial class Constants
|
||||
public const string ConfigDataTypes = ConfigPrefix + "DataTypes";
|
||||
public const string ConfigPackageManifests = ConfigPrefix + "PackageManifests";
|
||||
public const string ConfigWebhook = ConfigPrefix + "Webhook";
|
||||
public const string ConfigWebhookPayloadType = ConfigWebhook + ":PayloadType";
|
||||
public const string ConfigCache = ConfigPrefix + "Cache";
|
||||
|
||||
public static class NamedOptions
|
||||
|
||||
18
src/Umbraco.Core/Constants-Webhooks.cs
Normal file
18
src/Umbraco.Core/Constants-Webhooks.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Umbraco.Cms.Core.Webhooks;
|
||||
|
||||
namespace Umbraco.Cms.Core;
|
||||
|
||||
public static partial class Constants
|
||||
{
|
||||
public static class Webhooks
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the default webhook payload type.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Currently, the default payload type is <see cref="WebhookPayloadType.Legacy"/> for backward compatibility until Umbraco 17.
|
||||
/// From Umbraco 17 this will be changed to <see cref="WebhookPayloadType.Minimal"/>.
|
||||
/// </remarks>
|
||||
public const WebhookPayloadType DefaultPayloadType = WebhookPayloadType.Legacy;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Umbraco.Cms.Core.Actions;
|
||||
using Umbraco.Cms.Core.Cache;
|
||||
using Umbraco.Cms.Core.Composing;
|
||||
using Umbraco.Cms.Core.Configuration.Models;
|
||||
using Umbraco.Cms.Core.DeliveryApi;
|
||||
using Umbraco.Cms.Core.DynamicRoot.Origin;
|
||||
using Umbraco.Cms.Core.DynamicRoot.QuerySteps;
|
||||
@@ -91,7 +93,15 @@ public static partial class UmbracoBuilderExtensions
|
||||
builder.FilterHandlers().Add(() => builder.TypeLoader.GetTypes<IFilterHandler>());
|
||||
builder.SortHandlers().Add(() => builder.TypeLoader.GetTypes<ISortHandler>());
|
||||
builder.ContentIndexHandlers().Add(() => builder.TypeLoader.GetTypes<IContentIndexHandler>());
|
||||
builder.WebhookEvents().AddCms(true);
|
||||
|
||||
WebhookPayloadType webhookPayloadType = Constants.Webhooks.DefaultPayloadType;
|
||||
if (builder.Config.GetSection(Constants.Configuration.ConfigWebhookPayloadType).Value is not null)
|
||||
{
|
||||
webhookPayloadType = builder.Config.GetValue<WebhookPayloadType>(Constants.Configuration.ConfigWebhookPayloadType);
|
||||
}
|
||||
|
||||
builder.WebhookEvents().AddCms(true, webhookPayloadType);
|
||||
|
||||
builder.ContentTypeFilters();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ public class ContentCopiedWebhookEvent : WebhookEventBase<ContentCopiedNotificat
|
||||
{
|
||||
return new
|
||||
{
|
||||
notification.Copy,
|
||||
notification.Original,
|
||||
notification.ParentId,
|
||||
notification.RelateToOriginal
|
||||
Id = notification.Copy.Key,
|
||||
Original = notification.Original.Key,
|
||||
Parent = notification.ParentKey,
|
||||
notification.RelateToOriginal,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,5 @@ public class ContentDeletedBlueprintWebhookEvent : WebhookEventContentBase<Conte
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentDeletedBlueprintNotification notification) =>
|
||||
notification.DeletedBlueprints;
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity) => entity;
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity) => new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -9,17 +10,21 @@ namespace Umbraco.Cms.Core.Webhooks.Events;
|
||||
[WebhookEvent("Content Versions Deleted", Constants.WebhookEvents.Types.Content)]
|
||||
public class ContentDeletedVersionsWebhookEvent : WebhookEventBase<ContentDeletedVersionsNotification>
|
||||
{
|
||||
private readonly IIdKeyMap _idKeyMap;
|
||||
|
||||
public ContentDeletedVersionsWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IIdKeyMap idKeyMap)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
_idKeyMap = idKeyMap;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentDeletedVersions;
|
||||
@@ -28,10 +33,10 @@ public class ContentDeletedVersionsWebhookEvent : WebhookEventBase<ContentDelete
|
||||
{
|
||||
return new
|
||||
{
|
||||
notification.Id,
|
||||
Id = _idKeyMap.GetKeyForId(notification.Id, UmbracoObjectTypes.Document).Result,
|
||||
notification.DeletePriorVersions,
|
||||
notification.SpecificVersion,
|
||||
notification.DateToRetain
|
||||
notification.DateToRetain,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,6 @@ public class ContentDeletedWebhookEvent : WebhookEventContentBase<ContentDeleted
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentDeletedNotification notification) =>
|
||||
notification.DeletedEntities;
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity) => new DefaultPayloadModel { Id = entity.Key };
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity)
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -34,5 +34,6 @@ public class ContentEmptiedRecycleBinWebhookEvent : WebhookEventContentBase<Cont
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentEmptiedRecycleBinNotification notification) =>
|
||||
notification.DeletedEntities;
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IContent entity) => entity;
|
||||
protected override object? ConvertEntityToRequestPayload(IContent entity)
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -25,5 +26,5 @@ public class ContentMovedToRecycleBinWebhookEvent : WebhookEventBase<ContentMove
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentMovedToRecycleBin;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentMovedToRecycleBinNotification notification)
|
||||
=> notification.MoveInfoCollection;
|
||||
=> notification.MoveInfoCollection.Select(moveInfo => new DefaultPayloadModel { Id = moveInfo.Entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -25,5 +26,5 @@ public class ContentMovedWebhookEvent : WebhookEventBase<ContentMovedNotificatio
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentMoved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentMovedNotification notification)
|
||||
=> notification.MoveInfoCollection;
|
||||
=> notification.MoveInfoCollection.Select(moveInfo => new DefaultPayloadModel { Id = moveInfo.Entity.Key });
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ using Umbraco.Cms.Core.Notifications;
|
||||
using Umbraco.Cms.Core.PublishedCache;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
using Umbraco.Extensions;
|
||||
|
||||
namespace Umbraco.Cms.Core.Webhooks.Events;
|
||||
|
||||
@@ -38,8 +39,13 @@ public class ContentPublishedWebhookEvent : WebhookEventContentBase<ContentPubli
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentPublishedNotification notification) => notification.PublishedEntities;
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IContent entity)
|
||||
{
|
||||
IPublishedContent? publishedContent = _publishedContentCache.GetById(entity.Key);
|
||||
return publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
}
|
||||
=> new
|
||||
{
|
||||
Id = entity.Key,
|
||||
Cultures = entity.PublishCultureInfos?.Values.Select(cultureInfo => new
|
||||
{
|
||||
cultureInfo.Culture,
|
||||
cultureInfo.Date,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -39,9 +39,5 @@ public class ContentRolledBackWebhookEvent : WebhookEventContentBase<ContentRoll
|
||||
new List<IContent> { notification.Entity };
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IContent entity)
|
||||
{
|
||||
// Get preview/saved version of content for a rollback
|
||||
IPublishedContent? publishedContent = _contentCache.GetById(true, entity.Key);
|
||||
return publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
}
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -29,5 +29,6 @@ public class ContentSavedBlueprintWebhookEvent : WebhookEventContentBase<Content
|
||||
GetEntitiesFromNotification(ContentSavedBlueprintNotification notification)
|
||||
=> new List<IContent> { notification.SavedBlueprint };
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity) => entity;
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity)
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -39,9 +39,5 @@ public class ContentSavedWebhookEvent : WebhookEventContentBase<ContentSavedNoti
|
||||
notification.SavedEntities;
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IContent entity)
|
||||
{
|
||||
// Get preview/saved version of content
|
||||
IPublishedContent? publishedContent = _contentCache.GetById(true, entity.Key);
|
||||
return publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
}
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -36,14 +36,11 @@ public class ContentSortedWebhookEvent : WebhookEventBase<ContentSortedNotificat
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentSorted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentSortedNotification notification)
|
||||
{
|
||||
var sortedEntities = new List<object?>();
|
||||
foreach (var entity in notification.SortedEntities)
|
||||
{
|
||||
IPublishedContent? publishedContent = _contentCache.GetById(entity.Key);
|
||||
object? payload = publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
sortedEntities.Add(payload);
|
||||
}
|
||||
return sortedEntities;
|
||||
}
|
||||
=> notification.SortedEntities
|
||||
.OrderBy(entity => entity.SortOrder)
|
||||
.Select(entity => new
|
||||
{
|
||||
Id = entity.Key,
|
||||
entity.SortOrder,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -27,5 +27,6 @@ public class ContentUnpublishedWebhookEvent : WebhookEventContentBase<ContentUnp
|
||||
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentUnpublishedNotification notification) => notification.UnpublishedEntities;
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity) => new DefaultPayloadModel { Id = entity.Key };
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity)
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -21,5 +21,9 @@ public class DocumentTypeChangedWebhookEvent : WebhookEventBase<ContentTypeChang
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DocumentTypeChanged;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentTypeChangedNotification notification)
|
||||
=> notification.Changes;
|
||||
=> notification.Changes.Select(contentTypeChange => new
|
||||
{
|
||||
Id = contentTypeChange.Item.Key,
|
||||
ContentTypeChange = contentTypeChange.ChangeTypes,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class DocumentTypeDeletedWebhookEvent : WebhookEventBase<ContentTypeDelet
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DocumentTypeDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentTypeDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -21,5 +21,9 @@ public class DocumentTypeMovedWebhookEvent : WebhookEventBase<ContentTypeMovedNo
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DocumentTypeMoved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentTypeMovedNotification notification)
|
||||
=> notification.MoveInfoCollection;
|
||||
=> notification.MoveInfoCollection.Select(moveEvent => new
|
||||
{
|
||||
Id = moveEvent.Entity.Key,
|
||||
NewParentId = moveEvent.NewParentKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class DocumentTypeSavedWebhookEvent : WebhookEventBase<ContentTypeSavedNo
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DocumentTypeSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentTypeSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -21,5 +21,9 @@ public class MediaTypeChangedWebhookEvent : WebhookEventBase<MediaTypeChangedNot
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaTypeChanged;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MediaTypeChangedNotification notification)
|
||||
=> notification.Changes;
|
||||
=> notification.Changes.Select(contentTypeChange => new
|
||||
{
|
||||
Id = contentTypeChange.Item.Key,
|
||||
ContentTypeChange = contentTypeChange.ChangeTypes,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class MediaTypeDeletedWebhookEvent : WebhookEventBase<MediaTypeDeletedNot
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaTypeDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MediaTypeDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -21,5 +21,9 @@ public class MediaTypeMovedWebhookEvent : WebhookEventBase<MediaTypeMovedNotific
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaTypeMoved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MediaTypeMovedNotification notification)
|
||||
=> notification.MoveInfoCollection;
|
||||
=> notification.MoveInfoCollection.Select(moveEvent => new
|
||||
{
|
||||
Id = moveEvent.Entity.Key,
|
||||
NewParentId = moveEvent.NewParentKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class MediaTypeSavedWebhookEvent : WebhookEventBase<MediaTypeSavedNotific
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaTypeSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MediaTypeSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -21,5 +21,9 @@ public class MemberTypeChangedWebhookEvent : WebhookEventBase<MemberTypeChangedN
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MemberTypeChanged;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MemberTypeChangedNotification notification)
|
||||
=> notification.Changes;
|
||||
=> notification.Changes.Select(contentTypeChange => new
|
||||
{
|
||||
Id = contentTypeChange.Item.Key,
|
||||
ContentTypeChange = contentTypeChange.ChangeTypes,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class MemberTypeDeletedWebhookEvent : WebhookEventBase<MemberTypeDeletedN
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MemberTypeDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MemberTypeDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -21,5 +21,9 @@ public class MemberTypeMovedWebhookEvent : WebhookEventBase<MemberTypeMovedNotif
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MemberTypeMoved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MemberTypeMovedNotification notification)
|
||||
=> notification.MoveInfoCollection;
|
||||
=> notification.MoveInfoCollection.Select(moveEvent => new
|
||||
{
|
||||
Id = moveEvent.Entity.Key,
|
||||
NewParentId = moveEvent.NewParentKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,6 +21,6 @@ public class MemberTypeSavedWebhookEvent : WebhookEventBase<MemberTypeSavedNotif
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MemberTypeSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MemberTypeSavedNotification notification) =>
|
||||
notification.SavedEntities;
|
||||
public override object? ConvertNotificationToRequestPayload(MemberTypeSavedNotification notification)
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -7,7 +8,7 @@ using Umbraco.Cms.Core.Sync;
|
||||
namespace Umbraco.Cms.Core.Webhooks.Events;
|
||||
|
||||
[WebhookEvent("Data Type Deleted")]
|
||||
public class DataTypeDeletedWebhookEvent : WebhookEventBase<DataTypeSavedNotification>
|
||||
public class DataTypeDeletedWebhookEvent : WebhookEventBase<DataTypeDeletedNotification>
|
||||
{
|
||||
public DataTypeDeletedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
@@ -20,6 +21,6 @@ public class DataTypeDeletedWebhookEvent : WebhookEventBase<DataTypeSavedNotific
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DataTypeDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(DataTypeSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
public override object? ConvertNotificationToRequestPayload(DataTypeDeletedNotification notification)
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -21,5 +21,9 @@ public class DataTypeMovedWebhookEvent : WebhookEventBase<DataTypeMovedNotificat
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DataTypeMoved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(DataTypeMovedNotification notification)
|
||||
=> notification.MoveInfoCollection;
|
||||
=> notification.MoveInfoCollection.Select(moveEvent => new
|
||||
{
|
||||
Id = moveEvent.Entity.Key,
|
||||
NewParentId = moveEvent.NewParentKey,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class DataTypeSavedWebhookEvent : WebhookEventBase<DataTypeSavedNotificat
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DataTypeSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(DataTypeSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class DictionaryItemDeletedWebhookEvent : WebhookEventBase<DictionaryItem
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DictionaryItemDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(DictionaryItemDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class DictionaryItemSavedWebhookEvent : WebhookEventBase<DictionaryItemSa
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DictionaryItemSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(DictionaryItemSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class DomainDeletedWebhookEvent : WebhookEventBase<DomainDeletedNotificat
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DomainDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(DomainDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class DomainSavedWebhookEvent : WebhookEventBase<DomainSavedNotification>
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DomainSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(DomainSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class PartialViewDeletedWebhookEvent : WebhookEventBase<PartialViewDelete
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.PartialViewDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(PartialViewDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,6 +21,6 @@ public class PartialViewSavedWebhookEvent : WebhookEventBase<PartialViewSavedNot
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.PartialViewSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(PartialViewSavedNotification notification) =>
|
||||
notification.SavedEntities;
|
||||
public override object? ConvertNotificationToRequestPayload(PartialViewSavedNotification notification)
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class ScriptDeletedWebhookEvent : WebhookEventBase<ScriptDeletedNotificat
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ScriptDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ScriptDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -7,7 +8,7 @@ using Umbraco.Cms.Core.Sync;
|
||||
namespace Umbraco.Cms.Core.Webhooks.Events;
|
||||
|
||||
[WebhookEvent("Script Saved")]
|
||||
public class ScriptSavedWebhookEvent : WebhookEventBase<ScriptDeletedNotification>
|
||||
public class ScriptSavedWebhookEvent : WebhookEventBase<ScriptSavedNotification>
|
||||
{
|
||||
public ScriptSavedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
@@ -20,6 +21,6 @@ public class ScriptSavedWebhookEvent : WebhookEventBase<ScriptDeletedNotificatio
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ScriptSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ScriptDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
public override object? ConvertNotificationToRequestPayload(ScriptSavedNotification notification)
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,6 +21,6 @@ public class StylesheetDeletedWebhookEvent : WebhookEventBase<StylesheetDeletedN
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.StylesheetDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(StylesheetDeletedNotification notification) =>
|
||||
notification.DeletedEntities;
|
||||
public override object? ConvertNotificationToRequestPayload(StylesheetDeletedNotification notification)
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class StylesheetSavedWebhookEvent : WebhookEventBase<StylesheetSavedNotif
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.StylesheetSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(StylesheetSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,6 +21,6 @@ public class TemplateDeletedWebhookEvent : WebhookEventBase<TemplateDeletedNotif
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.TemplateDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(TemplateDeletedNotification notification) =>
|
||||
notification.DeletedEntities;
|
||||
public override object? ConvertNotificationToRequestPayload(TemplateDeletedNotification notification)
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,13 +22,9 @@ public class TemplateSavedWebhookEvent : WebhookEventBase<TemplateSavedNotificat
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.TemplateSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(TemplateSavedNotification notification)
|
||||
{
|
||||
// Create a new anonymous object with the properties we want
|
||||
return new
|
||||
=> notification.SavedEntities.Select(entity => new
|
||||
{
|
||||
notification.CreateTemplateForContentType,
|
||||
Id = entity.Key,
|
||||
notification.ContentTypeAlias,
|
||||
notification.SavedEntities
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -19,6 +19,14 @@ public class HealthCheckCompletedWebhookEvent : WebhookEventBase<HealthCheckComp
|
||||
new
|
||||
{
|
||||
notification.HealthCheckResults.AllChecksSuccessful,
|
||||
notification.HealthCheckResults.ResultsAsDictionary
|
||||
Results = notification.HealthCheckResults.ResultsAsDictionary.Select(result => new
|
||||
{
|
||||
result.Key,
|
||||
Statusus = result.Value.Select(x => new
|
||||
{
|
||||
ResultType = x.ResultType.ToString(),
|
||||
x.Message,
|
||||
}),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class LanguageDeletedWebhookEvent : WebhookEventBase<LanguageDeletedNotif
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.LanguageDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(LanguageDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,6 +22,6 @@ public class LanguageSavedWebhookEvent : WebhookEventBase<LanguageSavedNotificat
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.LanguageSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(LanguageSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ public class MediaDeletedWebhookEvent : WebhookEventContentBase<MediaDeletedNoti
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaDelete;
|
||||
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaDeletedNotification notification) => notification.DeletedEntities;
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key };
|
||||
protected override object ConvertEntityToRequestPayload(IMedia entity)
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ public class MediaEmptiedRecycleBinWebhookEvent : WebhookEventContentBase<MediaE
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaEmptiedRecycleBin;
|
||||
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaEmptiedRecycleBinNotification notification) => notification.DeletedEntities;
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaEmptiedRecycleBinNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key };
|
||||
protected override object ConvertEntityToRequestPayload(IMedia entity)
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ public class MediaMovedToRecycleBinWebhookEvent : WebhookEventContentBase<MediaM
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaMovedToRecycleBin;
|
||||
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaMovedToRecycleBinNotification notification) => notification.MoveInfoCollection.Select(x => x.Entity);
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaMovedToRecycleBinNotification notification)
|
||||
=> notification.MoveInfoCollection.Select(x => x.Entity);
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key };
|
||||
protected override object ConvertEntityToRequestPayload(IMedia entity)
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -25,7 +25,9 @@ public class MediaMovedWebhookEvent : WebhookEventContentBase<MediaMovedNotifica
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaMoved;
|
||||
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaMovedNotification notification) => notification.MoveInfoCollection.Select(x => x.Entity);
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaMovedNotification notification)
|
||||
=> notification.MoveInfoCollection.Select(x => x.Entity);
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IMedia entity) => new DefaultPayloadModel { Id = entity.Key };
|
||||
protected override object ConvertEntityToRequestPayload(IMedia entity)
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -35,11 +35,9 @@ public class MediaSavedWebhookEvent : WebhookEventContentBase<MediaSavedNotifica
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaSave;
|
||||
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaSavedNotification notification) => notification.SavedEntities;
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IMedia entity)
|
||||
{
|
||||
IPublishedContent? publishedContent = _mediaCache.GetById(entity.Key);
|
||||
return publishedContent is null ? null : _apiMediaBuilder.Build(publishedContent);
|
||||
}
|
||||
=> new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -9,14 +10,25 @@ namespace Umbraco.Cms.Core.Webhooks.Events;
|
||||
[WebhookEvent("Member Roles Assigned")]
|
||||
public class AssignedMemberRolesWebhookEvent : WebhookEventBase<AssignedMemberRolesNotification>
|
||||
{
|
||||
private readonly IIdKeyMap _idKeyMap;
|
||||
|
||||
public AssignedMemberRolesWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webHookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IIdKeyMap idKeyMap)
|
||||
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
|
||||
{
|
||||
_idKeyMap = idKeyMap;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.AssignedMemberRoles;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(AssignedMemberRolesNotification notification)
|
||||
=> new
|
||||
{
|
||||
Ids = notification.MemberIds.Select(id => _idKeyMap.GetKeyForId(id, UmbracoObjectTypes.Member).Result),
|
||||
notification.Roles,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,12 +22,5 @@ public class ExportedMemberWebhookEvent : WebhookEventBase<ExportedMemberNotific
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ExportedMember;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ExportedMemberNotification notification)
|
||||
{
|
||||
// No need to return the original member in the notification as well
|
||||
return new
|
||||
{
|
||||
exportedMember = notification.Exported
|
||||
};
|
||||
|
||||
}
|
||||
=> new DefaultPayloadModel { Id = notification.Member.Key };
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,19 +22,6 @@ public class MemberDeletedWebhookEvent : WebhookEventBase<MemberDeletedNotificat
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.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;
|
||||
}
|
||||
=> notification.DeletedEntities.Select(entity
|
||||
=> new DefaultPayloadModel { Id = entity.Key, });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class MemberGroupDeletedWebhookEvent : WebhookEventBase<MemberGroupDelete
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MemberGroupDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MemberGroupDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class MemberGroupSavedWebhookEvent : WebhookEventBase<MemberGroupSavedNot
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MemberGroupSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(MemberGroupSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel{ Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,19 +22,5 @@ public class MemberSavedWebhookEvent : WebhookEventBase<MemberSavedNotification>
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.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;
|
||||
}
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -9,14 +10,25 @@ namespace Umbraco.Cms.Core.Webhooks.Events;
|
||||
[WebhookEvent("Member Roles Removed")]
|
||||
public class RemovedMemberRolesWebhookEvent : WebhookEventBase<RemovedMemberRolesNotification>
|
||||
{
|
||||
private readonly IIdKeyMap _idKeyMap;
|
||||
|
||||
public RemovedMemberRolesWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webHookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IIdKeyMap idKeyMap)
|
||||
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
|
||||
{
|
||||
_idKeyMap = idKeyMap;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.RemovedMemberRoles;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(RemovedMemberRolesNotification notification)
|
||||
=> new
|
||||
{
|
||||
Ids = notification.MemberIds.Select(id => _idKeyMap.GetKeyForId(id, UmbracoObjectTypes.Member).Result),
|
||||
notification.Roles,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,4 +19,30 @@ public class ImportedPackageWebhookEvent : WebhookEventBase<ImportedPackageNotif
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.PackageImported;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ImportedPackageNotification notification)
|
||||
=> new
|
||||
{
|
||||
PackageName = notification.InstallationSummary.PackageName,
|
||||
InstalledEntities = new
|
||||
{
|
||||
ContentIds = notification.InstallationSummary.ContentInstalled.Select(x => x.Key),
|
||||
LanguagesIds = notification.InstallationSummary.LanguagesInstalled.Select(x => x.Key),
|
||||
MediaIds = notification.InstallationSummary.MediaInstalled.Select(x => x.Key),
|
||||
ScriptsIds = notification.InstallationSummary.ScriptsInstalled.Select(x => x.Key),
|
||||
StyleSheetsIds = notification.InstallationSummary.StylesheetsInstalled.Select(x => x.Key),
|
||||
TemplatesIds = notification.InstallationSummary.TemplatesInstalled.Select(x => x.Key),
|
||||
DataTypesIds = notification.InstallationSummary.DataTypesInstalled.Select(x => x.Key),
|
||||
DictionaryItemsIds = notification.InstallationSummary.DictionaryItemsInstalled.Select(x => x.Key),
|
||||
DocumentTypesIds = notification.InstallationSummary.DocumentTypesInstalled.Select(x => x.Key),
|
||||
EntityContainersIds = notification.InstallationSummary.EntityContainersInstalled.Select(x => x.Key),
|
||||
MediaTypesIds = notification.InstallationSummary.MediaTypesInstalled.Select(x => x.Key),
|
||||
PartialViewsIds = notification.InstallationSummary.PartialViewsInstalled.Select(x => x.Key),
|
||||
},
|
||||
Warnings = new
|
||||
{
|
||||
ConflictingStylesheetsIds = notification.InstallationSummary.Warnings.ConflictingStylesheets?.Select(x => x?.Key).Where(x => x is not null) ?? [],
|
||||
ConflictingTemplatesIds = notification.InstallationSummary.Warnings.ConflictingTemplates?.Select(x => x.Key) ?? [],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,5 +21,6 @@ public class PublicAccessEntryDeletedWebhookEvent : WebhookEventBase<PublicAcces
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.PublicAccessEntryDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(PublicAccessEntryDeletedNotification notification) => notification.DeletedEntities;
|
||||
public override object? ConvertNotificationToRequestPayload(PublicAccessEntryDeletedNotification notification)
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class PublicAccessEntrySavedWebhookEvent : WebhookEventBase<PublicAccessE
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.PublicAccessEntrySaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(PublicAccessEntrySavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class RelationDeletedWebhookEvent : WebhookEventBase<RelationDeletedNotif
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.RelationDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(RelationDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class RelationSavedWebhookEvent : WebhookEventBase<RelationSavedNotificat
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.RelationSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(RelationSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -22,5 +23,5 @@ public class RelationTypeDeletedWebhookEvent : WebhookEventBase<RelationTypeDele
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.RelationTypeDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(RelationTypeDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,5 +22,5 @@ public class RelationTypeSavedWebhookEvent : WebhookEventBase<RelationTypeSavedN
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.RelationTypeSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(RelationTypeSavedNotification notification)
|
||||
=> notification.SavedEntities;
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -9,17 +10,25 @@ namespace Umbraco.Cms.Core.Webhooks.Events;
|
||||
[WebhookEvent("User Group Permissions Assigned")]
|
||||
public class AssignedUserGroupPermissionsWebhookEvent : WebhookEventBase<AssignedUserGroupPermissionsNotification>
|
||||
{
|
||||
private readonly IIdKeyMap _idKeyMap;
|
||||
|
||||
public AssignedUserGroupPermissionsWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webHookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IIdKeyMap idKeyMap)
|
||||
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
|
||||
{
|
||||
_idKeyMap = idKeyMap;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.AssignedUserGroupPermissions;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(AssignedUserGroupPermissionsNotification notification)
|
||||
=> notification.EntityPermissions;
|
||||
=> notification.EntityPermissions.Select(permission =>
|
||||
new {
|
||||
UserId = _idKeyMap.GetKeyForId(permission.EntityId, UmbracoObjectTypes.Unknown).Result,
|
||||
UserGroupId = _idKeyMap.GetKeyForId(permission.UserGroupId, UmbracoObjectTypes.Unknown).Result,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,19 +22,5 @@ public class UserDeletedWebhookEvent : WebhookEventBase<UserDeletedNotification>
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.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;
|
||||
}
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,4 +21,12 @@ public class UserForgotPasswordRequestedWebhookEvent : WebhookEventBase<UserForg
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserForgotPasswordRequested;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserForgotPasswordRequestedNotification notification)
|
||||
=> new DefaultPayloadModel
|
||||
{
|
||||
Id = notification.AffectedUserId is not null &&
|
||||
Guid.TryParse(notification.AffectedUserId, out Guid affectedUserGuid)
|
||||
? affectedUserGuid
|
||||
: Guid.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,5 +21,6 @@ public class UserGroupDeletedWebhookEvent : WebhookEventBase<UserGroupDeletedNot
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserGroupDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserGroupDeletedNotification notification) => notification.DeletedEntities;
|
||||
public override object? ConvertNotificationToRequestPayload(UserGroupDeletedNotification notification)
|
||||
=> notification.DeletedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,5 +21,6 @@ public class UserGroupSavedWebhookEvent : WebhookEventBase<UserGroupSavedNotific
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserGroupSaved;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserGroupSavedNotification notification) => notification.SavedEntities;
|
||||
public override object? ConvertNotificationToRequestPayload(UserGroupSavedNotification notification)
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -19,4 +20,13 @@ public class UserLockedWebhookEvent : WebhookEventBase<UserLockedNotification>
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserLocked;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserLockedNotification notification)
|
||||
=> new DefaultPayloadModel
|
||||
{
|
||||
Id = notification.AffectedUserId is not null &&
|
||||
Guid.TryParse(notification.AffectedUserId, out Guid affectedUserGuid)
|
||||
? affectedUserGuid
|
||||
: Guid.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -19,4 +20,13 @@ public class UserLoginFailedWebhookEvent : WebhookEventBase<UserLoginFailedNotif
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserLoginFailed;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserLoginFailedNotification notification)
|
||||
=> new DefaultPayloadModel
|
||||
{
|
||||
Id = notification.AffectedUserId is not null &&
|
||||
Guid.TryParse(notification.AffectedUserId, out Guid affectedUserGuid)
|
||||
? affectedUserGuid
|
||||
: Guid.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,4 +21,12 @@ public class UserLoginRequiresVerificationWebhookEvent : WebhookEventBase<UserLo
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserLoginRequiresVerification;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserLoginRequiresVerificationNotification notification)
|
||||
=> new DefaultPayloadModel
|
||||
{
|
||||
Id = notification.AffectedUserId is not null &&
|
||||
Guid.TryParse(notification.AffectedUserId, out Guid affectedUserGuid)
|
||||
? affectedUserGuid
|
||||
: Guid.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -19,4 +20,13 @@ public class UserLoginSuccessWebhookEvent : WebhookEventBase<UserLoginSuccessNot
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserLoginSuccess;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserLoginSuccessNotification notification)
|
||||
=> new DefaultPayloadModel
|
||||
{
|
||||
Id = notification.AffectedUserId is not null &&
|
||||
Guid.TryParse(notification.AffectedUserId, out Guid affectedUserGuid)
|
||||
? affectedUserGuid
|
||||
: Guid.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -19,4 +20,13 @@ public class UserLogoutSuccessWebhookEvent : WebhookEventBase<UserLogoutSuccessN
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserLogoutSuccess;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserLogoutSuccessNotification notification)
|
||||
=> new DefaultPayloadModel
|
||||
{
|
||||
Id = notification.AffectedUserId is not null &&
|
||||
Guid.TryParse(notification.AffectedUserId, out Guid affectedUserGuid)
|
||||
? affectedUserGuid
|
||||
: Guid.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,4 +21,15 @@ public class UserPasswordChangedWebhookEvent : WebhookEventBase<UserPasswordChan
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserPasswordChanged;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserPasswordChangedNotification notification)
|
||||
=> new
|
||||
{
|
||||
Id = notification.AffectedUserId is not null &&
|
||||
Guid.TryParse(notification.AffectedUserId, out Guid affectedUserGuid)
|
||||
? affectedUserGuid
|
||||
: Guid.Empty,
|
||||
PerformingId = Guid.TryParse(notification.PerformingUserId, out Guid performingUserGuid)
|
||||
? performingUserGuid
|
||||
: Guid.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,4 +19,16 @@ public class UserPasswordResetWebhookEvent : WebhookEventBase<UserPasswordResetN
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserPasswordReset;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserPasswordResetNotification notification)
|
||||
=> new
|
||||
{
|
||||
Id = notification.AffectedUserId is not null &&
|
||||
Guid.TryParse(notification.AffectedUserId, out Guid affectedUserGuid)
|
||||
? affectedUserGuid
|
||||
: Guid.Empty,
|
||||
PerformingId = Guid.TryParse(notification.AffectedUserId, out Guid performingUserGuid)
|
||||
? performingUserGuid
|
||||
: Guid.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -21,19 +22,5 @@ public class UserSavedWebhookEvent : WebhookEventBase<UserSavedNotification>
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.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;
|
||||
}
|
||||
=> notification.SavedEntities.Select(entity => new DefaultPayloadModel { Id = entity.Key });
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
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;
|
||||
@@ -20,4 +21,6 @@ public class UserTwoFactorRequestedWebhookEvent : WebhookEventBase<UserTwoFactor
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserTwoFactorRequested;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserTwoFactorRequestedNotification notification)
|
||||
=> new DefaultPayloadModel { Id = notification.UserKey };
|
||||
}
|
||||
|
||||
@@ -19,4 +19,16 @@ public class UserUnlockedWebhookEvent : WebhookEventBase<UserUnlockedNotificatio
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.UserUnlocked;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(UserUnlockedNotification notification)
|
||||
=> new
|
||||
{
|
||||
Id = notification.AffectedUserId is not null &&
|
||||
Guid.TryParse(notification.AffectedUserId, out Guid affectedUserGuid)
|
||||
? affectedUserGuid
|
||||
: Guid.Empty,
|
||||
PerformingId = Guid.TryParse(notification.AffectedUserId, out Guid performingUserGuid)
|
||||
? performingUserGuid
|
||||
: Guid.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
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.DeliveryApi;
|
||||
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;
|
||||
|
||||
[WebhookEvent("Content Published", Constants.WebhookEvents.Types.Content)]
|
||||
public class ExtendedContentPublishedWebhookEvent : ExtendedContentWebhookEventBase<ContentPublishedNotification>
|
||||
{
|
||||
private readonly IApiContentResponseBuilder _apiContentBuilder;
|
||||
private readonly IPublishedContentCache _publishedContentCache;
|
||||
|
||||
public ExtendedContentPublishedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IApiContentResponseBuilder apiContentBuilder,
|
||||
IPublishedContentCache publishedContentCache,
|
||||
IOutputExpansionStrategyAccessor outputExpansionStrategyAccessor,
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor,
|
||||
outputExpansionStrategyAccessor,
|
||||
variationContextAccessor)
|
||||
{
|
||||
_apiContentBuilder = apiContentBuilder;
|
||||
_publishedContentCache = publishedContentCache;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentPublish;
|
||||
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentPublishedNotification notification) =>
|
||||
notification.PublishedEntities;
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IContent entity)
|
||||
{
|
||||
IPublishedContent? publishedContent = _publishedContentCache.GetById(entity.Key);
|
||||
IApiContentResponse? deliveryContent =
|
||||
publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
|
||||
if (deliveryContent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Dictionary<string, object> cultures = BuildCultureProperties(publishedContent!, deliveryContent);
|
||||
|
||||
return new
|
||||
{
|
||||
deliveryContent.Id,
|
||||
deliveryContent.ContentType,
|
||||
deliveryContent.Name,
|
||||
deliveryContent.CreateDate,
|
||||
deliveryContent.UpdateDate,
|
||||
Cultures = cultures,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
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.DeliveryApi;
|
||||
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;
|
||||
|
||||
[WebhookEvent("Content Saved", Constants.WebhookEvents.Types.Content)]
|
||||
public class ExtendedContentSavedWebhookEvent : ExtendedContentWebhookEventBase<ContentSavedNotification>
|
||||
{
|
||||
private readonly IApiContentResponseBuilder _apiContentBuilder;
|
||||
private readonly IPublishedContentCache _contentCache;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
private readonly IOutputExpansionStrategyAccessor _outputExpansionStrategyAccessor;
|
||||
|
||||
public ExtendedContentSavedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IApiContentResponseBuilder apiContentBuilder,
|
||||
IPublishedContentCache contentCache,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
IOutputExpansionStrategyAccessor outputExpansionStrategyAccessor)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor,
|
||||
outputExpansionStrategyAccessor,
|
||||
variationContextAccessor)
|
||||
{
|
||||
_apiContentBuilder = apiContentBuilder;
|
||||
_contentCache = contentCache;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
_outputExpansionStrategyAccessor = outputExpansionStrategyAccessor;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentSaved;
|
||||
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentSavedNotification notification) =>
|
||||
notification.SavedEntities;
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IContent entity)
|
||||
{
|
||||
// Get preview/saved version of content
|
||||
IPublishedContent? publishedContent = _contentCache.GetById(true, entity.Key);
|
||||
IApiContentResponse? deliveryContent = publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
|
||||
if (deliveryContent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Dictionary<string, object> cultures = BuildCultureProperties(publishedContent!, deliveryContent);
|
||||
|
||||
return new
|
||||
{
|
||||
deliveryContent.Id,
|
||||
deliveryContent.ContentType,
|
||||
deliveryContent.Name,
|
||||
deliveryContent.CreateDate,
|
||||
deliveryContent.UpdateDate,
|
||||
Cultures = cultures,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
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.DeliveryApi;
|
||||
using Umbraco.Cms.Core.Models.PublishedContent;
|
||||
using Umbraco.Cms.Core.Notifications;
|
||||
using Umbraco.Cms.Core.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Webhooks.Events;
|
||||
|
||||
public abstract class ExtendedContentWebhookEventBase<TNotification> : WebhookEventContentBase<TNotification, IContent>
|
||||
where TNotification : INotification
|
||||
{
|
||||
private readonly IOutputExpansionStrategyAccessor _outputExpansionStrategyAccessor;
|
||||
private readonly IVariationContextAccessor _variationContextAccessor;
|
||||
|
||||
public ExtendedContentWebhookEventBase(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IOutputExpansionStrategyAccessor outputExpansionStrategyAccessor,
|
||||
IVariationContextAccessor variationContextAccessor)
|
||||
: base(webhookFiringService, webhookService, webhookSettings, serverRoleAccessor)
|
||||
{
|
||||
_outputExpansionStrategyAccessor = outputExpansionStrategyAccessor;
|
||||
_variationContextAccessor = variationContextAccessor;
|
||||
}
|
||||
|
||||
public Dictionary<string, object> BuildCultureProperties(
|
||||
IPublishedContent publishedContent,
|
||||
IApiContentResponse deliveryContent)
|
||||
{
|
||||
var cultures = new Dictionary<string, object>();
|
||||
|
||||
// just to be safe that messing with the variationContext doesn't screw things up
|
||||
VariationContext? originalVariationContext = _variationContextAccessor.VariationContext;
|
||||
|
||||
try
|
||||
{
|
||||
foreach (KeyValuePair<string, IApiContentRoute> culture in deliveryContent.Cultures)
|
||||
{
|
||||
_variationContextAccessor.VariationContext = new VariationContext(culture.Key);
|
||||
|
||||
IDictionary<string, object?> properties =
|
||||
_outputExpansionStrategyAccessor.TryGetValue(out IOutputExpansionStrategy? outputExpansionStrategy)
|
||||
? outputExpansionStrategy.MapContentProperties(publishedContent!)
|
||||
: new Dictionary<string, object?>();
|
||||
|
||||
cultures.Add(culture.Key, new { culture.Value.Path, culture.Value.StartItem, properties, });
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
_variationContextAccessor.VariationContext = originalVariationContext;
|
||||
}
|
||||
|
||||
return cultures;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
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;
|
||||
|
||||
// todo: convert to proper extended media event when deliveryApi models are fixed
|
||||
[WebhookEvent("Media Saved", Constants.WebhookEvents.Types.Media)]
|
||||
public class ExtendedMediaSavedWebhookEvent : WebhookEventContentBase<MediaSavedNotification, IMedia>
|
||||
{
|
||||
private readonly IPublishedMediaCache _mediaCache;
|
||||
private readonly IApiMediaBuilder _apiMediaBuilder;
|
||||
|
||||
public ExtendedMediaSavedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IPublishedMediaCache mediaCache,
|
||||
IApiMediaBuilder apiMediaBuilder)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
_mediaCache = mediaCache;
|
||||
_apiMediaBuilder = apiMediaBuilder;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.MediaSave;
|
||||
|
||||
protected override IEnumerable<IMedia> GetEntitiesFromNotification(MediaSavedNotification notification) => notification.SavedEntities;
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IMedia entity)
|
||||
{
|
||||
IPublishedContent? publishedContent = _mediaCache.GetById(entity.Key);
|
||||
return publishedContent is null ? null : _apiMediaBuilder.Build(publishedContent);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Content Copied", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentCopiedWebhookEvent : WebhookEventBase<ContentCopiedNotification>
|
||||
{
|
||||
public LegacyContentCopiedWebhookEvent(
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Content Template [Blueprint] Deleted", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentDeletedBlueprintWebhookEvent : WebhookEventContentBase<ContentDeletedBlueprintNotification, IContent>
|
||||
{
|
||||
public LegacyContentDeletedBlueprintWebhookEvent(
|
||||
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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Content Versions Deleted", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentDeletedVersionsWebhookEvent : WebhookEventBase<ContentDeletedVersionsNotification>
|
||||
{
|
||||
public LegacyContentDeletedVersionsWebhookEvent(
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Content Deleted", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentDeletedWebhookEvent : WebhookEventContentBase<ContentDeletedNotification, IContent>
|
||||
{
|
||||
public LegacyContentDeletedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentDelete;
|
||||
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentDeletedNotification notification) =>
|
||||
notification.DeletedEntities;
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity) => new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
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.Services;
|
||||
using Umbraco.Cms.Core.Sync;
|
||||
|
||||
namespace Umbraco.Cms.Core.Webhooks.Events;
|
||||
|
||||
[WebhookEvent("Content Recycle Bin Emptied", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentEmptiedRecycleBinWebhookEvent : WebhookEventContentBase<ContentEmptiedRecycleBinNotification, IContent>
|
||||
{
|
||||
private readonly IApiContentBuilder _apiContentBuilder;
|
||||
|
||||
public LegacyContentEmptiedRecycleBinWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IApiContentBuilder apiContentBuilder)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
_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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Content Moved to Recycle Bin", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentMovedToRecycleBinWebhookEvent : WebhookEventBase<ContentMovedToRecycleBinNotification>
|
||||
{
|
||||
public LegacyContentMovedToRecycleBinWebhookEvent(
|
||||
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;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Content Moved", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentMovedWebhookEvent : WebhookEventBase<ContentMovedNotification>
|
||||
{
|
||||
public LegacyContentMovedWebhookEvent(
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
|
||||
[WebhookEvent("Content Published", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentPublishedWebhookEvent : WebhookEventContentBase<ContentPublishedNotification, IContent>
|
||||
{
|
||||
private readonly IApiContentBuilder _apiContentBuilder;
|
||||
private readonly IPublishedContentCache _publishedContentCache;
|
||||
|
||||
public LegacyContentPublishedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IApiContentBuilder apiContentBuilder,
|
||||
IPublishedContentCache publishedContentCache)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
_apiContentBuilder = apiContentBuilder;
|
||||
_publishedContentCache = publishedContentCache;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentPublish;
|
||||
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentPublishedNotification notification) => notification.PublishedEntities;
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IContent entity)
|
||||
{
|
||||
IPublishedContent? publishedContent = _publishedContentCache.GetById(entity.Key);
|
||||
return publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
|
||||
[WebhookEvent("Content Rolled Back", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentRolledBackWebhookEvent : WebhookEventContentBase<ContentRolledBackNotification, IContent>
|
||||
{
|
||||
private readonly IPublishedContentCache _contentCache;
|
||||
private readonly IApiContentBuilder _apiContentBuilder;
|
||||
|
||||
public LegacyContentRolledBackWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IPublishedContentCache contentCache,
|
||||
IApiContentBuilder apiContentBuilder)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
_contentCache = contentCache;
|
||||
_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)
|
||||
{
|
||||
// Get preview/saved version of content for a rollback
|
||||
IPublishedContent? publishedContent = _contentCache.GetById(true, entity.Key);
|
||||
return publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Content Template [Blueprint] Saved", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentSavedBlueprintWebhookEvent : WebhookEventContentBase<ContentSavedBlueprintNotification, IContent>
|
||||
{
|
||||
public LegacyContentSavedBlueprintWebhookEvent(
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
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;
|
||||
|
||||
[WebhookEvent("Content Saved", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentSavedWebhookEvent : WebhookEventContentBase<ContentSavedNotification, IContent>
|
||||
{
|
||||
private readonly IApiContentBuilder _apiContentBuilder;
|
||||
private readonly IPublishedContentCache _contentCache;
|
||||
|
||||
public LegacyContentSavedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IApiContentBuilder apiContentBuilder,
|
||||
IPublishedContentCache contentCache)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
_apiContentBuilder = apiContentBuilder;
|
||||
_contentCache = contentCache;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentSaved;
|
||||
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentSavedNotification notification) =>
|
||||
notification.SavedEntities;
|
||||
|
||||
protected override object? ConvertEntityToRequestPayload(IContent entity)
|
||||
{
|
||||
// Get preview/saved version of content
|
||||
IPublishedContent? publishedContent = _contentCache.GetById(true, entity.Key);
|
||||
return publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
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;
|
||||
|
||||
[WebhookEvent("Content Sorted", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentSortedWebhookEvent : WebhookEventBase<ContentSortedNotification>
|
||||
{
|
||||
private readonly IPublishedContentCache _contentCache;
|
||||
private readonly IApiContentBuilder _apiContentBuilder;
|
||||
|
||||
public LegacyContentSortedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor,
|
||||
IPublishedContentCache contentCache,
|
||||
IApiContentBuilder apiContentBuilder)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
_contentCache = contentCache;
|
||||
_apiContentBuilder = apiContentBuilder;
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentSorted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentSortedNotification notification)
|
||||
{
|
||||
var sortedEntities = new List<object?>();
|
||||
foreach (var entity in notification.SortedEntities)
|
||||
{
|
||||
IPublishedContent? publishedContent = _contentCache.GetById(entity.Key);
|
||||
object? payload = publishedContent is null ? null : _apiContentBuilder.Build(publishedContent);
|
||||
sortedEntities.Add(payload);
|
||||
}
|
||||
return sortedEntities;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Content Unpublished", Constants.WebhookEvents.Types.Content)]
|
||||
public class LegacyContentUnpublishedWebhookEvent : WebhookEventContentBase<ContentUnpublishedNotification, IContent>
|
||||
{
|
||||
public LegacyContentUnpublishedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webhookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
: base(
|
||||
webhookFiringService,
|
||||
webhookService,
|
||||
webhookSettings,
|
||||
serverRoleAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.ContentUnpublish;
|
||||
|
||||
protected override IEnumerable<IContent> GetEntitiesFromNotification(ContentUnpublishedNotification notification) => notification.UnpublishedEntities;
|
||||
|
||||
protected override object ConvertEntityToRequestPayload(IContent entity) => new DefaultPayloadModel { Id = entity.Key };
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Document Type Changed")]
|
||||
public class LegacyDocumentTypeChangedWebhookEvent : WebhookEventBase<ContentTypeChangedNotification>
|
||||
{
|
||||
public LegacyDocumentTypeChangedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webHookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DocumentTypeChanged;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentTypeChangedNotification notification)
|
||||
=> notification.Changes;
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
[WebhookEvent("Document Type Deleted")]
|
||||
public class LegacyDocumentTypeDeletedWebhookEvent : WebhookEventBase<ContentTypeDeletedNotification>
|
||||
{
|
||||
public LegacyDocumentTypeDeletedWebhookEvent(
|
||||
IWebhookFiringService webhookFiringService,
|
||||
IWebhookService webHookService,
|
||||
IOptionsMonitor<WebhookSettings> webhookSettings,
|
||||
IServerRoleAccessor serverRoleAccessor)
|
||||
: base(webhookFiringService, webHookService, webhookSettings, serverRoleAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
public override string Alias => Constants.WebhookEvents.Aliases.DocumentTypeDeleted;
|
||||
|
||||
public override object? ConvertNotificationToRequestPayload(ContentTypeDeletedNotification notification)
|
||||
=> notification.DeletedEntities;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user