chore(rest): migrate /api/v1/users.getPresence to OpenAPI endpoint definition

Closed
YA
6mo ago
+58-42

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

Endpoints migrated

EndpointMethodOld PatternNew Pattern
users.getPresenceGETaddRoute.get() chained

Architectural changes

  • Replaced legacy API.v1.addRoute('users.getPresence', ...) with the new chained .get('users.getPresence', ...) method
  • Added 400, 401 error response schemas using validateBadRequestErrorResponse and validateUnauthorizedErrorResponse
  • Added AJV response schema for 200 response with presence, connectionStatus, and lastLogin fields
  • Added query: undefined explicitly as per new pattern guidelines
  • connectionStatus and lastLogin are optional — only returned for own user requests
  • lastLogin serialized as ISO string for JSON compatibility

Files changed

  • apps/meteor/app/api/server/v1/users.ts — Main migration
  • .changeset/migrate-users-getPresence-openapi.md — Changeset entry
  • packages\rest-typings\src\v1\users.ts — Remove old manual typing

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

  • API Updates

    • users.getPresence now returns presence for other users, and for your own user also includes connectionStatus and optional lastLogin (ISO string).
    • The endpoint is now served via the consolidated API surface with stricter response validation for more consistent responses.
  • Documentation

    • OpenAPI documentation updated to reflect the new response shape and validation.