Mirrored from GitHub github.com/roostorg/coop

ncmec: add `email` schema field role for reported user (closes #839) (#840) master

* ncmec: add `email` schema field role for reported user Closes #839. Adopters whose NCMEC additional-info webhook isn't configured (or returns no email) get reports rejected as "incomplete" because no other path populates the email. This adds an `email` field role on user item types, parallel to the existing `ipAddress` role, sourced from a user-schema string field of the adopter's choosing. The submit codepath now prefers `userAdditionalInfo.email` from the NCMEC additional-info webhook when present, falling back to the field-role email otherwise (via new `resolveReportedPersonEmail` helper). Migration adds `email_field` to `public.item_types` and its temporal mirror, with a STRING-type CHECK constraint mirroring the existing `display_name_field` pattern. The `item_type_versions` materialized view is dropped and recreated to include the new column, with all four indexes and the dependent `item_type_latest_versions` view rebuilt. Admin UI adds `Email` to the role picker for user item types. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ncmec: address PR #840 review feedback - Migration: include `created_at` in the recreated `item_type_versions` materialized view to match the column declared in `dbTypes.ts`. The previous `add_ip_address_field_role_to_item_types` migration omitted it; this PR recovers parity. - `resolveReportedPersonEmail`: trim the field-role email and treat whitespace-only as absent, so we don't ship `{ _text: " " }` to NCMEC (which would fail the same way the original bug did). - Tests: two new cases on `resolveReportedPersonEmail` cover the trim and whitespace-only paths. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ncmec: revert created_at addition to MV; fix dbTypes drift instead The previous commit added `created_at` to the `item_type_versions` materialized view in response to a CodeRabbit comment about `dbTypes.ts` declaring the column. CI revealed the column doesn't exist on `public.item_types_history`, so the UNION ALL SELECT failed: ERROR: column item_types_history.created_at does not exist The actual drift was in `dbTypes.ts` claiming a column the MV has never had. Remove the type declaration to match reality. The MV itself stays unchanged from the previous (working) `ip_address` migration's shape. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ncmec: update USER item type inline snapshot for email field role CI surfaced one inline snapshot in moderationConfigService.test.ts that didn't include the new `email: undefined` key on `schemaFieldRoles`. Snapshot updated to match the new shape. CONTENT and THREAD snapshots are unaffected since email is USER-only. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>