chore: migrate audit DDP methods to /v1/audit.* REST endpoints (EE)

Merged
GG
3mo ago
+706-204

Summary

Continues the DDP→REST sweep (#40659, #40711, #40675, #40724, #40728, #40734). This batch migrates the three auditGet* DDP methods that backed the EE audit panel. DDP methods stay registered for external SDK/mobile clients with deprecation logs pointing at the new routes.

New endpoints (EE — auditing license required)

DDP methodREST endpointPermissionBody / query
auditGetAuditionsGET /v1/audit.auditionscan-audit-log?startDate=&endDate= (ISO)
auditGetMessagesPOST /v1/audit.messagescan-audit{ rid?, startDate, endDate, users, msg, type, visitor?, agent? }
auditGetOmnichannelMessagesPOST /v1/audit.omnichannel.messagescan-audit{ startDate, endDate, users, msg, type, visitor?, agent? }

Each endpoint is rate-limited at 10/60s (matching the DDP DDPRateLimiter rules) and writes the same AuditLog entry the DDP path produced. Dates are serialized as ISO strings on the wire.

Implementation

  • Method bodies extracted into apps/meteor/ee/server/lib/audit/functions.ts; DDP entrypoints become thin + deprecation-logged.
  • messages and omnichannel.messages are POST because the audit log insertion is a side effect (write) and the query params include arrays (users) that don't serialize cleanly into query strings.

Client changes

  • AuditLogTable → useEndpoint('GET', '/v1/audit.auditions')
  • useAuditMutation → useEndpoint('POST', '/v1/audit.messages') + useEndpoint('POST', '/v1/audit.omnichannel.messages')
  • Dates serialized via .toISOString().

Test plan

  • CI green (lint + typecheck)
  • Admin (EE) → Audit → Messages panel filter by user/channel/date → results render, audit log entry created
  • Audit → Omnichannel messages panel by visitor/agent/date → results render
  • Audit → Audit log table (can-audit-log perm) → past entries render
  • Hit the endpoints with curl and confirm 403 without license/permission, 200 with both

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added EE-only REST API endpoints for audit auditions, audit messages, and omnichannel audit messages under /v1/audit.* (rate-limited to 10 requests per 60 seconds).
    • Updated the Audit UI to fetch auditions and messages via the new REST routes.
  • Bug Fixes
    • Standardized startDate/endDate handling as ISO strings and normalized REST responses to consistently return auditions/messages.
  • Chores
    • Kept legacy audit methods available with deprecation notices directing callers to the REST endpoints until 9.0.0.

Task: ARCH-2269