ncmec: auto-populate priorCTReports, originalFileName, fileRelevance (#855)
* ncmec: auto-populate priorCTReports, originalFileName, fileRelevance
Closes three code-gap rows from the field-coverage audit on #843, all
auto-populated from data coop already has so no adopter configuration
is needed:
- `personOrUserReported.priorCTReports[]`: query
`ncmec_reporting.ncmec_reports` for accepted (`is_test=false`) report
IDs for the same reported user, ordered most-recent-first. Skipped for
exttest submissions since prod and test report IDs don't
cross-reference.
- `fileDetails.originalFileName`: derive from the media URL's pathname
(decoded last segment). Webhook-supplied `additionalInfo.fileName`
wins when present; URL-derived fills the gap for adopters without an
additional-info webhook.
- `fileDetails.fileRelevance`: default to `'Reported'` since
`submitReport`'s current call path only iterates over reviewer-flagged
media. Input slot accepts `'Supplemental Reported'` for future use.
Touch points:
- `NcmecReportingService.getPriorCTReportIds`: new query method.
- `BuildSubmitReportObjectInput.priorCTReports`: new input slot;
`buildSubmitReportObject` renders inside `personOrUserReported` after
`ipCaptureEvent` per XSD insertion order.
- `BuildFileDetailsObjectInput.{originalFileName,fileRelevance}`: new
input slots; `buildFileDetailsObject` renders them in their XSD
positions (3rd and 8th).
- `deriveOriginalFileNameFromUrl`: exported helper; `#upload` uses it
to populate `originalFileName` from `media.url` before calling
`buildFileDetailsObject`.
No migration; no GraphQL/SDL change; no client change. Purely additive
server behavior: existing reports gain three new elements, no existing
elements change.
Tests:
- `deriveOriginalFileNameFromUrl` (new describe block): decoding,
query/fragment stripping, unparseable URLs, malformed percent-encoding
fallback.
- `buildFileDetailsObject` (extended): updated minimum-envelope and
XSD-order expectations for the new elements; new cases for
`fileRelevance` default+override and `originalFileName` emit/omit.
- `buildSubmitReportObject` (new describe block): `priorCTReports`
populates in the right XSD position; omits when empty or unset.
All 69 NCMEC unit tests pass locally.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* ncmec: log fallback paths in deriveOriginalFileNameFromUrl
Surfaces each of the four fallback cases (unparseable URL, empty
pathname, empty decoded segment, decode failure) via `ncmecDebugLog` so
operators can triage unexpected media URL shapes under `NCMEC_DEBUG=1`.
Addresses review nit on #855.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>