mirror of https://github.com/Squidex/squidex.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.7 KiB
49 lines
1.7 KiB
// ==========================================================================
|
|
// 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<ContentCreated>(
|
|
"created content item.");
|
|
|
|
AddEventMessage<ContentUpdated>(
|
|
"updated content item.");
|
|
|
|
AddEventMessage<ContentDeleted>(
|
|
"deleted content item.");
|
|
|
|
AddEventMessage<ContentStatusChanged>(
|
|
"changed status of content item to {[Status]}.");
|
|
}
|
|
|
|
protected override Task<HistoryEventToStore> CreateEventCoreAsync(Envelope<IEvent> @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);
|
|
}
|
|
}
|
|
}
|
|
|