-
Notifications
You must be signed in to change notification settings - Fork 13.7k
chore: migrate presence endpoints to new API pattern #38882
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ggazzo
merged 10 commits into
RocketChat:develop
from
smirk-dev:refactor/migrate-presence-api-chained-pattern
Feb 25, 2026
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
12db41e
refactor: migrate presence endpoints to new chained API pattern
smirk-dev 1d10f16
chore: retrigger CI
smirk-dev d114662
chore: retrigger CI for unit tests
smirk-dev 183bd29
test: increase waitFor timeout for lazy-loaded components in Markup spec
smirk-dev 9fbaa28
chore: retrigger CI
smirk-dev 9b0406e
fix: address CodeRabbit review comments
smirk-dev 9d732ee
fix: use success({}) to match response schema type
smirk-dev f9a2253
Update refactor-presence-api-chained-pattern.md
ggazzo dd3e46b
Remove timeout from waitFor in Markup tests
ggazzo 6efacf2
Merge branch 'develop' into refactor/migrate-presence-api-chained-pat…
smirk-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Migrated `presence.getConnections` and `presence.enableBroadcast` REST API endpoints from legacy `addRoute` pattern to the new chained `.get()`/`.post()` API pattern with typed response schemas. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,63 @@ | ||
| import { Presence } from '@rocket.chat/core-services'; | ||
| import { ajv, validateUnauthorizedErrorResponse, validateForbiddenErrorResponse } from '@rocket.chat/rest-typings'; | ||
|
|
||
| import { API } from '../api'; | ||
|
|
||
| API.v1.addRoute( | ||
| API.v1.get( | ||
| 'presence.getConnections', | ||
| { authRequired: true, permissionsRequired: ['manage-user-status'] }, | ||
| { | ||
| async get() { | ||
| const result = await Presence.getConnectionCount(); | ||
|
|
||
| return API.v1.success(result); | ||
| authRequired: true, | ||
| permissionsRequired: ['manage-user-status'], | ||
| response: { | ||
| 200: ajv.compile<{ current: number; max: number }>({ | ||
| type: 'object', | ||
| properties: { | ||
| current: { type: 'number' }, | ||
| max: { type: 'number' }, | ||
| success: { | ||
| type: 'boolean', | ||
| enum: [true], | ||
| }, | ||
| }, | ||
| required: ['current', 'max', 'success'], | ||
| additionalProperties: false, | ||
| }), | ||
| 401: validateUnauthorizedErrorResponse, | ||
| 403: validateForbiddenErrorResponse, | ||
| }, | ||
| }, | ||
| async function action() { | ||
| const result = await Presence.getConnectionCount(); | ||
|
|
||
| return API.v1.success(result); | ||
| }, | ||
| ); | ||
|
|
||
| API.v1.addRoute( | ||
| API.v1.post( | ||
| 'presence.enableBroadcast', | ||
| { authRequired: true, permissionsRequired: ['manage-user-status'], twoFactorRequired: true }, | ||
| { | ||
| async post() { | ||
| await Presence.toggleBroadcast(true); | ||
|
|
||
| return API.v1.success(); | ||
| authRequired: true, | ||
| permissionsRequired: ['manage-user-status'], | ||
| twoFactorRequired: true, | ||
| response: { | ||
| 200: ajv.compile<void>({ | ||
| type: 'object', | ||
| properties: { | ||
| success: { | ||
| type: 'boolean', | ||
| enum: [true], | ||
| }, | ||
| }, | ||
| required: ['success'], | ||
| additionalProperties: false, | ||
| }), | ||
|
smirk-dev marked this conversation as resolved.
Outdated
|
||
| 401: validateUnauthorizedErrorResponse, | ||
| 403: validateForbiddenErrorResponse, | ||
| }, | ||
| }, | ||
| async function action() { | ||
| await Presence.toggleBroadcast(true); | ||
|
|
||
| return API.v1.success(); | ||
| }, | ||
| ); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.