chore: migrate users.setStatus endpoint to new OpenAPI pattern with AJV validation

Closed
YA
6mo ago
+113-91

Proposed changes

Migrates the users.setStatus REST API endpoint from the legacy API.v1.addRoute pattern to the new chained API.v1.post() pattern with AJV request body and response schema validation and OpenAPI documentation support.

Closes #34983

Endpoints migrated

EndpointMethodOld PatternNew Pattern
users.setStatusPOSTaddRoute.post().post() chained

Architectural changes

  • Replaced legacy API.v1.addRoute('users.setStatus', ...) with the new chained .post('users.setStatus', ...) method
  • Added AJV body schema validation for status, message, userId, username, user fields
  • Added 400, 401, 403 error response schemas
  • Added AJV response schema for 200 response
  • Wired up ExtractRoutesFromAPI + declare module for automatic type inference
  • Removed manual /v1/users.setStatus typing from rest-typings (now inferred via module augmentation)

Files changed

  • apps/meteor/app/api/server/v1/users.ts — Main migration
  • packages/rest-typings/src/v1/users.ts — Removed old manual typing
  • apps/meteor/tests/end-to-end/api/users.ts — Updated test assertions to match new AJV error format

Related project

This continues the REST API migration effort described in the GSoC 2026 project: Replace old REST API definitions over the new API.

cc @diego-sampaio @ggazzo

This PR is part of the ongoing REST API migration effort tracked in RocketChat/Rocket.Chat-Open-API#150

Summary by CodeRabbit

  • Improvements
    • Enhanced the users.setStatus API endpoint with improved request validation, comprehensive error handling, and better OpenAPI documentation support.
    • Added rate limiting to the endpoint for improved stability.
    • Consolidated and modernized the endpoint implementation for consistency with the rest of the API.