Skip to content

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

Draft
ggazzo wants to merge 2 commits into
developfrom
chore/ddp-migrate-batch6-audit
Draft

chore: migrate audit DDP methods to /v1/audit.* REST endpoints (EE)#40736
ggazzo wants to merge 2 commits into
developfrom
chore/ddp-migrate-batch6-audit

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented May 29, 2026

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.
  • 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

  • AuditLogTableuseEndpoint('GET', '/v1/audit.auditions')
  • useAuditMutationuseEndpoint('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

Added three new REST endpoints (EE-only, license: auditing) covering
the audit flows that previously only existed as DDP methods:

- GET  /v1/audit.auditions             (auditGetAuditions)
- POST /v1/audit.messages              (auditGetMessages)
- POST /v1/audit.omnichannel.messages  (auditGetOmnichannelMessages)

Method bodies extracted into apps/meteor/ee/server/lib/audit/functions.ts
and reused by both DDP entrypoints (now thin + deprecation-logged) and
the new REST handlers. Each REST endpoint:

- requires the same per-action permission (can-audit / can-audit-log).
- is rate-limited at 10/60s matching the DDP DDPRateLimiter rules.
- writes the same AuditLog entry the DDP path produced.
- accepts dates as ISO strings on the wire (parsed server-side).

Client AuditLogTable + useAuditMutation swapped from useMethod to
useEndpoint; date params serialized via toISOString().

DDP methods stay registered with deprecation logs pointing at the new
routes until 9.0.0.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 29, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 29, 2026

🦋 Changeset detected

Latest commit: 4a5e8a2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Minor
@rocket.chat/core-typings Minor
@rocket.chat/rest-typings Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 23cbf49f-c953-451f-9c90-49ee2df847d7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.74%. Comparing base (b92bcc7) to head (4a5e8a2).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40736      +/-   ##
===========================================
- Coverage    69.76%   69.74%   -0.02%     
===========================================
  Files         3327     3327              
  Lines       123134   123134              
  Branches     21963    21955       -8     
===========================================
- Hits         85902    85881      -21     
- Misses       33873    33893      +20     
- Partials      3359     3360       +1     
Flag Coverage Δ
unit 70.44% <ø> (-0.04%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

- Add response schemas to /v1/audit.{auditions,messages,omnichannel.messages}
  so TypedOptions infers queryParams/bodyParams correctly.
- mapMessageFromApi() each REST message in useAuditMutation so caller
  AuditResult receives IMessage[] (Date) instead of Serialized<IMessage>[].
- Cast AuditLogEntry value through unknown→IAuditLog since the REST
  response carries dates as strings while the consumer reads IAuditLog
  (the component formats the Date itself, so the cast is just to satisfy
  TS — same pattern other audit-adjacent code uses).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant