From b496ac947798efd0278567eb8a44be57e0395e50 Mon Sep 17 00:00:00 2001 From: Niek Otten Date: Fri, 28 Aug 2026 12:38:27 +0200 Subject: [PATCH] refactor(event-subscriber): drop the hoofdObject fallback (refs #153) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For a `resource: object` notification Objecten sends the object as both hoofdObject and resourceUrl — the object *is* the main resource — so `HoofdObject ?? ResourceUrl` was a branch that can never take its left side and that no test could distinguish. It came across from the zaken path, where hoofdObject genuinely differed (the zaak behind a status). Tests unchanged and green. --- .../event-subscriber/EventSubscriber.Api/Program.cs | 9 +++++---- .../EventSubscriber.Application/Notification.cs | 10 +++++----- .../NotificationProjectorTests.cs | 2 +- .../Steps/RegisterProjectieBijwerkenSteps.cs | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/services/event-subscriber/EventSubscriber.Api/Program.cs b/services/event-subscriber/EventSubscriber.Api/Program.cs index 07a4656..4505095 100644 --- a/services/event-subscriber/EventSubscriber.Api/Program.cs +++ b/services/event-subscriber/EventSubscriber.Api/Program.cs @@ -84,11 +84,12 @@ app.MapPost("/admin/rebuild", async (NotificationProjector projector, Cancellati await app.RunAsync(); -/// The NRC notification body, as Open Notificaties POSTs it. Only the fields the -/// projection needs are bound; aanmaakdatum/kenmerken are ignored for the minimal slice. -public sealed record NotificationDto(string Kanaal, string Resource, string Actie, Uri ResourceUrl, Uri? HoofdObject = null) +/// The NRC notification body, as Open Notificaties POSTs it. Only the fields the projector +/// needs are bound; aanmaakdatum, kenmerken and hoofdObject are ignored — for a +/// register write hoofdObject is the same object as resourceUrl (ADR-0030). +public sealed record NotificationDto(string Kanaal, string Resource, string Actie, Uri ResourceUrl) { - public Notification ToNotification() => new(Kanaal, Resource, Actie, ResourceUrl, HoofdObject); + public Notification ToNotification() => new(Kanaal, Resource, Actie, ResourceUrl); } public partial class Program diff --git a/services/event-subscriber/EventSubscriber.Application/Notification.cs b/services/event-subscriber/EventSubscriber.Application/Notification.cs index 76a013a..b04672a 100644 --- a/services/event-subscriber/EventSubscriber.Application/Notification.cs +++ b/services/event-subscriber/EventSubscriber.Application/Notification.cs @@ -16,15 +16,15 @@ public sealed record Notification( string Kanaal, string Resource, string Actie, - Uri ResourceUrl, - Uri? HoofdObject = null) + Uri ResourceUrl) { /// A register record written to Objecten — create on submit, update on /// approval, since the ACL upserts the same object for a registration (§8.6). public bool IsRegisterRecordWritten => Kanaal == "objecten" && Resource == "object" && Actie is "create" or "update"; - /// The object holding the register record. Objecten sets both fields to the object; - /// hoofdObject is the main resource by definition, so prefer it. - public Uri ObjectUrl => HoofdObject ?? ResourceUrl; + /// The object holding the register record. For a resource: object notification + /// Objecten sends the object as both hoofdObject and resourceUrl — the object is + /// the main resource — so the notification's own hoofdObject is not modelled. + public Uri ObjectUrl => ResourceUrl; } diff --git a/services/event-subscriber/EventSubscriber.Tests/NotificationProjectorTests.cs b/services/event-subscriber/EventSubscriber.Tests/NotificationProjectorTests.cs index 25aab00..39e733b 100644 --- a/services/event-subscriber/EventSubscriber.Tests/NotificationProjectorTests.cs +++ b/services/event-subscriber/EventSubscriber.Tests/NotificationProjectorTests.cs @@ -22,7 +22,7 @@ public sealed class NotificationProjectorTests private Notification RecordWritten(string actie = "create", string url = ObjectUrl, string status = RegistrationStatus.Ingediend, string zaakId = ZaakId) { _acl.Records[url] = new RegisterRecord(zaakId, status, "REG-2026-0001"); - return new Notification("objecten", "object", actie, new Uri(url), new Uri(url)); + return new Notification("objecten", "object", actie, new Uri(url)); } [Fact] diff --git a/tests/acceptance/Steps/RegisterProjectieBijwerkenSteps.cs b/tests/acceptance/Steps/RegisterProjectieBijwerkenSteps.cs index b2e535c..ae0e09e 100644 --- a/tests/acceptance/Steps/RegisterProjectieBijwerkenSteps.cs +++ b/tests/acceptance/Steps/RegisterProjectieBijwerkenSteps.cs @@ -28,7 +28,7 @@ public sealed class RegisterProjectieBijwerkenSteps // The ACL upserts one object per registration, so submit and approval share an object URL. var objectUrl = ObjectBase + id; _register.Records[objectUrl] = new RegisterRecord(id, status, "REG-" + id); - _notification = new Notification("objecten", "object", "create", new Uri(objectUrl), new Uri(objectUrl)); + _notification = new Notification("objecten", "object", "create", new Uri(objectUrl)); } [Given("the register notification is delivered to the event subscriber")]