Files
Umbraco-CMS/src/Umbraco.Core/Models/IAuditEntry.cs
Laura Neto 7fc2bc84de Audit entries rework (#19345)
* Introduce new AuditEntryService

- Moved logic related to the IAuditEntryRepository from the AuditService to the new service
- Introduced new Async methods
  - Using ids (for easier transition from the previous Write method)
  - Using keys
- Moved and updated integration tests related to the audit entries to a new test class `AuditEntryServiceTests`
- Added unit tests class `AuditEntryServiceTests` and added a few unit tests
- Added migration to add columns for `performingUserKey` and `affectedUserKey` and convert existing user ids
- Adjusted usages of the old AuditService.Write method to use the new one (mostly notification handlers)

* Apply suggestions from code review

* Small improvement

* Some adjustments following code review. Removed UnknownUserKey and used null instead.

* Small adjustments

* Better handle audits performed during the migration state

* Update TODO comment
2025-06-06 13:12:35 +02:00

84 lines
2.7 KiB
C#

using Umbraco.Cms.Core.Models.Entities;
namespace Umbraco.Cms.Core.Models;
/// <summary>
/// Represents an audited event.
/// </summary>
/// <remarks>
/// <para>
/// The free-form details properties can be used to capture relevant infos (for example,
/// a user email and identifier) at the time of the audited event, even though they may change
/// later on - but we want to keep a track of their value at that time.
/// </para>
/// <para>
/// Depending on audit loggers, these properties can be purely free-form text, or
/// contain json serialized objects.
/// </para>
/// </remarks>
public interface IAuditEntry : IEntity, IRememberBeingDirty
{
/// <summary>
/// Gets or sets the identifier of the user triggering the audited event.
/// </summary>
int PerformingUserId { get; set; }
/// <summary>
/// Gets or sets the key of the user triggering the audited event.
/// </summary>
// TODO (V19): Remove the default implementations from this interface.
Guid? PerformingUserKey
{
get => null;
set { }
}
/// <summary>
/// Gets or sets free-form details about the user triggering the audited event.
/// </summary>
string? PerformingDetails { get; set; }
/// <summary>
/// Gets or sets the IP address or the request triggering the audited event.
/// </summary>
string? PerformingIp { get; set; }
/// <summary>
/// Gets or sets the date and time of the audited event.
/// </summary>
DateTime EventDateUtc { get; set; }
/// <summary>
/// Gets or sets the identifier of the user affected by the audited event.
/// </summary>
/// <remarks>Not used when no single user is affected by the event.</remarks>
int AffectedUserId { get; set; }
/// <summary>
/// Gets or sets the key of the user affected by the audited event.
/// </summary>
/// <remarks>Not used when no single user is affected by the event.</remarks>
// TODO (V19): Remove the default implementations from this interface.
Guid? AffectedUserKey
{
get => null;
set { }
}
/// <summary>
/// Gets or sets free-form details about the entity affected by the audited event.
/// </summary>
/// <remarks>The entity affected by the event can be another user, a member...</remarks>
string? AffectedDetails { get; set; }
/// <summary>
/// Gets or sets the type of the audited event.
/// </summary>
string? EventType { get; set; }
/// <summary>
/// Gets or sets free-form details about the audited event.
/// </summary>
string? EventDetails { get; set; }
}