From 5934c7561d25f3c27ef64e12a567baba878f2680 Mon Sep 17 00:00:00 2001 From: Magne Helleborg Date: Wed, 16 Oct 2024 14:24:40 +0200 Subject: [PATCH] Clientside guardrails --- .../Redaction/PersonalDataRedactedForEvent.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Source/Events/Redaction/PersonalDataRedactedForEvent.cs b/Source/Events/Redaction/PersonalDataRedactedForEvent.cs index 2b6eba07..07d0aff2 100644 --- a/Source/Events/Redaction/PersonalDataRedactedForEvent.cs +++ b/Source/Events/Redaction/PersonalDataRedactedForEvent.cs @@ -1,6 +1,7 @@ // Copyright (c) Dolittle. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; @@ -10,9 +11,14 @@ namespace Dolittle.SDK.Events.Redaction; /// Event that triggers redaction of the given personal data /// It will target the given event type and redact the properties specified within the EventSourceId of the event /// -[EventType("de1e7e17-bad5-da7a-fad4-fbc6ec3c0ea5")] +[EventType(PersonalDataRedactedId)] public class PersonalDataRedactedForEvent { + /// + /// This is recognized by the runtime, and triggers redaction of the selected personal data + /// + public const string PersonalDataRedactedId = "de1e7e17-bad5-da7a-fad4-fbc6ec3c0ea5"; + private static readonly Guid _id = Guid.Parse(PersonalDataRedactedId); public string EventId { get; init; } public string EventAlias { get; init; } public Dictionary RedactedProperties { get; init; } @@ -54,6 +60,12 @@ public static bool TryCreate(string reason, string redactedBy, return false; } + if (eventType.Id.Equals(_id)) + { + error = "Cannot create redaction event for redaction event"; + return false; + } + var redactedFields = RedactedType.RedactedProperties; if (redactedFields.Count == 0) {