chore: migrate audit DDP methods to /v1/audit.* REST endpoints (EE)
Merged
GG
3mo ago+706+706+012345678901234567890123456789-204-204-012345678901234567890123456789
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 method | REST endpoint | Permission | Body / query |
|---|---|---|---|
auditGetAuditions | GET /v1/audit.auditions | can-audit-log | ?startDate=&endDate= (ISO) |
auditGetMessages | POST /v1/audit.messages | can-audit | { rid?, startDate, endDate, users, msg, type, visitor?, agent? } |
auditGetOmnichannelMessages | POST /v1/audit.omnichannel.messages | can-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. messagesandomnichannel.messagesarePOSTbecause 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-logperm) → past entries render - Hit the endpoints with
curland 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.
- Added EE-only REST API endpoints for audit auditions, audit messages, and omnichannel audit messages under
- Bug Fixes
- Standardized
startDate/endDatehandling as ISO strings and normalized REST responses to consistently returnauditions/messages.
- Standardized
- Chores
- Kept legacy audit methods available with deprecation notices directing callers to the REST endpoints until 9.0.0.
Task: ARCH-2269