Skip to content

Record media changes in the audit trail, on the entity they belong to - #8

Merged
sadeqabuhattem merged 5 commits into
mainfrom
feature/media-audit-participant
Nov 17, 2026
Merged

sadeqabuhattem merged 5 commits into
mainfrom
feature/media-audit-participant

Conversation

@sadeqabuhattem

Copy link
Copy Markdown
Member

What

Media changes now show up in the audit trail where people look for them: an image attached to a product is in that product's history, and a file's own upload, edit and delete are under ("Media", <file id>). Built on DotNetBoost.Media 1.0.0-preview.3's write participants (dotnetboost/media#5).

Before, Auditing's interceptor recorded Media's raw rows: an attach was a MediaAttachment entry addressed by the link's own GUID, a soft delete was a MediaFile change to DeletedAt, and the product's history said nothing.

Format

MediaAuditParticipant writes one Updated entry on the owner per media operation — the role as the row, file names as the values, and the operation in the entry's Metadata:

Operation Entry Row Metadata
attach Category 4 Banner: — → photo.png {"media":"Attach","fileId":"…"}
detach Category 4 Banner: photo.png → — {"media":"Detach","fileId":"…"}
replace Category 4 Banner: photo.png → new.png {"media":"Replace","fileId":"…","previousFileId":"…"}
reorder Product 42 Gallery: a.png, b.png → b.png, a.png {"media":"Reorder"}

Upload, edit and delete are Created, Updated and Deleted on ("Media", <file id>), with only the properties the file has. A delete also writes a detach on each owner marked "reason":"FileDeleted", and lists those owners on the file's own entry as one Attachments row.

Every entry commits in the media store's own SaveChanges, so it is saved with its change or not at all; a failure to record fails the media write. IgnoreEntity<MediaFile>() and IgnoreEntity<MediaAttachment>() keep the raw rows out.

Dashboard

The audit page reads the media metadata and shows the operation as a badge beside the action — Attached, Detached, Replaced, Reordered — in the table and the entry details, in en/ar/fr. Entries without that metadata are drawn as before.

Upgrade

The four DotNetBoost.Media.* pins move from 1.0.0-preview.2 to 1.0.0-preview.3.

Tests

  • .NET: 178 passed, 0 skipped, built with -p:UseLocalDotNetBoost=false against the nuget.org packages. New integration tests cover a product image's life in the product and file trails, a replacement and a reorder as one entry each, and a media write that fails after its entry was enlisted leaving nothing behind.
  • Dashboard: lint, typecheck, 24 unit tests and 13 Playwright tests pass; the badge was checked in light and dark, English and Arabic, and at 375px.

README section 9 describes the participant; documented counts are updated.

🤖 Generated with Claude Code

sadeqabuhattem and others added 5 commits November 16, 2026 19:32
MediaAuditParticipant, a DotNetBoost.Media write participant, records each
media change as an audit entry enlisted in the media store's own save:
attach, detach and reorder as an Updated entry on the owner (so a
product's trail shows its images), upload, edit and delete on
("Media", <file id>). IgnoreEntity<MediaFile>() and
IgnoreEntity<MediaAttachment>() keep the raw rows out of the trail.

Tests cover a product image's life in the product and file trails, and a
media write that fails after its entry was enlisted leaving nothing
behind. Docs and documented counts updated.

Needs DotNetBoost.Media's write participants, which arrive in the release
after 1.0.0-preview.2; until then this builds only against local source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MediaAuditParticipant now writes one Updated entry on the product or
category per media operation: the role as the row (Banner, Gallery), file
names as the values, and the operation in Metadata as JSON
({"media":"Attach|Detach|Replace|Reorder","fileId":...}). A replace is one
entry (old file -> new file), a reorder one entry with the whole order
before and after, and a file delete adds a detach on each owner marked
"reason":"FileDeleted". Upload, edit and delete stay on ("Media", id),
without rows for properties the file never had.

Built on DotNetBoost.Media's one-change-per-operation reporting; needs the
Media release after 1.0.0-preview.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Deleted entry under ("Media", id) gains one Attachments row naming
every entity the file was still attached to ("Category 4 as banner,
Product 42 as gallery"), so the file's history is complete on its own.
Each owner still gets its detach entry marked "reason":"FileDeleted", so
its history stays accurate too. The row is left out for a file attached
to nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Media changes are all Updated entries on their owner, with the operation
in the entry's metadata ({"media":"Attach|Detach|Replace|Reorder"}). The
audit page now reads that convention and draws a badge beside the action
- Attached, Detached, Replaced, Reordered - in the trail table and in the
entry's details. A detach caused by a file delete shows "Detached" with
its own icon in the table and "Detached, file deleted" on hover and in
the details. Entries without that metadata are drawn as before.

Long metadata now wraps instead of running off the row. Strings in en, ar
and fr; a unit test for reading the metadata and an e2e check for the
badge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The four DotNetBoost.Media pins move from 1.0.0-preview.2 to the release
that adds write participants, which MediaAuditParticipant is built on.
Until now this branch built only against the local source. Built and
tested with -p:UseLocalDotNetBoost=false against the nuget.org packages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sadeqabuhattem
sadeqabuhattem merged commit 0f7e76f into main Nov 17, 2026
2 checks passed
@sadeqabuhattem
sadeqabuhattem deleted the feature/media-audit-participant branch November 17, 2026 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant