|
1 | 1 | import { MeteorError, Team, api, Calendar } from '@rocket.chat/core-services'; |
2 | | -import type { IExportOperation, ILoginToken, IPersonalAccessToken, IUser, UserStatus } from '@rocket.chat/core-typings'; |
| 2 | +import type { IExportOperation, ILoginToken, ISubscription, IPersonalAccessToken, IUser, UserStatus } from '@rocket.chat/core-typings'; |
3 | 3 | import { Users, Subscriptions, Sessions } from '@rocket.chat/models'; |
4 | 4 | import { |
5 | 5 | isUserCreateParamsPOST, |
@@ -425,6 +425,10 @@ API.v1.addRoute( |
425 | 425 | }, |
426 | 426 | ); |
427 | 427 |
|
| 428 | +type UsersInfoResponseUser = IUser & { |
| 429 | + rooms?: Pick<ISubscription, 'rid' | 'name' | 't' | 'roles' | 'unread'>[]; |
| 430 | +}; |
| 431 | + |
428 | 432 | const usersInfoEndpoint = API.v1.get( |
429 | 433 | 'users.info', |
430 | 434 | { |
@@ -467,10 +471,31 @@ const usersInfoEndpoint = API.v1.get( |
467 | 471 | response: { |
468 | 472 | 400: validateBadRequestErrorResponse, |
469 | 473 | 401: validateUnauthorizedErrorResponse, |
470 | | - 200: ajv.compile<{ user: IUser; success: true }>({ |
| 474 | + 200: ajv.compile<{ user: UsersInfoResponseUser; success: true }>({ |
471 | 475 | type: 'object', |
472 | 476 | properties: { |
473 | | - user: { type: 'object' }, |
| 477 | + user: { |
| 478 | + type: 'object', |
| 479 | + properties: { |
| 480 | + rooms: { |
| 481 | + type: 'array', |
| 482 | + items: { |
| 483 | + type: 'object', |
| 484 | + properties: { |
| 485 | + rid: { type: 'string' }, |
| 486 | + name: { type: 'string' }, |
| 487 | + t: { type: 'string' }, |
| 488 | + roles: { type: 'array', items: { type: 'string' } }, |
| 489 | + unread: { type: 'number' }, |
| 490 | + federated: { type: 'boolean' }, |
| 491 | + }, |
| 492 | + required: ['rid', 't', 'unread'], |
| 493 | + additionalProperties: false, |
| 494 | + }, |
| 495 | + }, |
| 496 | + }, |
| 497 | + additionalProperties: true, |
| 498 | + }, |
474 | 499 | success: { type: 'boolean', enum: [true] }, |
475 | 500 | }, |
476 | 501 | required: ['user', 'success'], |
|
0 commit comments