// ========================================================================== // ContentHistoryEventsCreator.cs // Squidex Headless CMS // ========================================================================== // Copyright (c) Squidex Group // All rights reserved. // ========================================================================== using System.Threading.Tasks; using Squidex.Domain.Apps.Entities.History; using Squidex.Domain.Apps.Events.Contents; using Squidex.Infrastructure; using Squidex.Infrastructure.EventSourcing; namespace Squidex.Domain.Apps.Entities.Contents { public sealed class ContentHistoryEventsCreator : HistoryEventsCreatorBase { public ContentHistoryEventsCreator(TypeNameRegistry typeNameRegistry) : base(typeNameRegistry) { AddEventMessage( "created content item."); AddEventMessage( "updated content item."); AddEventMessage( "deleted content item."); AddEventMessage( "changed status of content item to {[Status]}."); } protected override Task CreateEventCoreAsync(Envelope @event) { var channel = $"contents.{@event.Headers.AggregateId()}"; var result = ForEvent(@event.Payload, channel); if (@event.Payload is ContentStatusChanged contentStatusChanged) { result = result.AddParameter("Status", contentStatusChanged.Status); } return Task.FromResult(result); } } }