5 Commits

Author SHA1 Message Date
zurdi
fabbeef3f1 fix(audit): address the Greptile review
- Record a firmware or rom delete once its row is gone, with whether the
  file actually left the disk, even when cleaning up after it fails.
- Record a download only once there's a response to send, so a missing
  file or a failed zip isn't logged.
- Release a download's, sign-in's or reset request's dedupe claim when its
  event can't be stored, so a retry records it.
- Count the games a collection actually gained or lost.
- Queue the reset-request event before the email, which stops the tasks
  after it when it fails.
- Let an event's data be a lookup, run inside the recorder's error
  handling, for the hide, unhide and permission events.
- Follow a query change while the Events tab stays open, and don't show a
  load error once it has closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 12:55:23 +02:00
zurdi
d9d65d8b56 refactor(audit): apply the pr-ready simplify pass
- record() takes the request as its actor, and a target can be a
  function: the lookups that name it now run inside the recorder's error
  handling, and for downloads only once the dedupe lets them record.
  That also restores the minimal visibility query on the file route.
- One changed_fields/change pair for rom, user, collection and platform
  edits, one collection helper, AuditActor.anonymous, a shared
  count_in_window and current_device_id, one test helper for recorded
  events and one fixture for audit events.
- The describers share simple/counted/visibility builders and the
  eventData readers with notifications, join lists per locale, and treat
  any *.delete as unlinked.
- EventLog builds one item list with the phase folded in, keeps each
  event's sentence across pages, formats days once, and loads users
  through the users store.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 02:45:12 +02:00
zurdi
6298e7bf8c fix(audit): apply the pr-ready code review
- Hide events on roms of a hidden platform from non-admins.
- Pin later pages to the highest matching id the API returns, not the
  first row's: rows are ordered by when they happened, so a play synced
  late has a higher id than newer events and was dropped.
- Cap recorded failed sign-ins per address, dedupe reset requests and
  record them in the background with the email, and hash claim keys.
- Keep another user's private collection by id only in bulk downloads.
- Check a Range start without int(), which raises past 4300 digits.
- Clear the list when a reload fails, load more only once it's shown,
  report a cover change only when the user made one, label only rom and
  platform unhides, accept an actor kind the API doesn't know.
- One client IP helper, date-fns for today and yesterday, one time
  formatter for the list, no em-dashes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 02:30:47 +02:00
zurdi
1aa614c321 fix(audit): report only the rom fields a user edited
A save turns null cover and manual urls into empty strings, and a rename
re-derives the sort name; neither is an edit of its own. Also fixes the
test helpers the first local run caught.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:33:29 +02:00
zurdi
0afbe2ef57 feat(audit): add the audit_events table, recorder and read API
A persistent record of what users, or RomM itself, did. Admins read
everyone's events through GET /api/audit-events; anyone else gets only
their own. Events older than AUDIT_LOG_RETENTION_DAYS (90 by default,
0 keeps them) are pruned nightly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-24 01:05:59 +02:00