On each notification the subscriber reads the zaak's reference (identificatie) through the ACL — the only code allowed to talk to ZGW (§8.1) — and persists it on the register_projection row and in the processed_notifications replay log. Storing it in the log keeps rebuild log-only (ADR-0008): no ACL/ZGW access on rebuild. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
42 lines
2.1 KiB
C#
42 lines
2.1 KiB
C#
namespace EventSubscriber.Application;
|
|
|
|
/// <summary>
|
|
/// An inbound NRC (Open Notificaties) notification, as Open Notificaties POSTs it to an
|
|
/// abonnement callback. Only the fields the projection needs are modelled; the full ZGW
|
|
/// "Notificatie" resource also carries <c>aanmaakdatum</c> and <c>kenmerken</c> which the
|
|
/// minimal projection ignores (bsn is deferred — see ADR-0008). For a <c>zaken</c>/<c>zaak</c>/<c>create</c>
|
|
/// notification <c>hoofdObject</c> and <c>resourceUrl</c> are both the created zaak's URL.
|
|
/// </summary>
|
|
public sealed record Notification(
|
|
string Kanaal,
|
|
string Resource,
|
|
string Actie,
|
|
Uri ResourceUrl,
|
|
Uri? HoofdObject = null)
|
|
{
|
|
/// <summary>A zaak being created — projected as INGEDIEND.</summary>
|
|
public bool IsZaakCreated =>
|
|
Kanaal == "zaken" && Resource == "zaak" && Actie == "create";
|
|
|
|
/// <summary>A status being set on a zaak — the approval, projected as INGESCHREVEN (S-09b). In the
|
|
/// walking skeleton the only status ever set after creation is the approval, and the subscriber may
|
|
/// not read OpenZaak (§8.1), so any status-create is taken as the approval.</summary>
|
|
public bool IsZaakStatusSet =>
|
|
Kanaal == "zaken" && Resource == "status" && Actie == "create";
|
|
|
|
/// <summary>The zaak URL this notification concerns — <c>hoofdObject</c> (the zaak) for a status
|
|
/// notification, else the resource URL (which, for a zaak-create, is the zaak).</summary>
|
|
public Uri ZaakUrl => HoofdObject ?? ResourceUrl;
|
|
|
|
/// <summary>The zaak UUID used as the projection key — the trailing segment of <see cref="ZaakUrl"/>.</summary>
|
|
public string ZaakId => ZaakUrl.Segments[^1].Trim('/');
|
|
|
|
/// <summary>
|
|
/// A deterministic dedup key. Open Notificaties carries no notification id and may
|
|
/// redeliver, so the key is derived from the immutable notification content: two
|
|
/// deliveries of the same zaak-create collapse to one. (NRC may also deliver
|
|
/// out of order; the projector tolerates that — order does not change the outcome.)
|
|
/// </summary>
|
|
public string IdempotencyKey => $"{Kanaal}:{Resource}:{Actie}:{ResourceUrl}";
|
|
}
|