Skip to content

Commit f1261d9

Browse files
fix: validation for rooms
1 parent 2379646 commit f1261d9

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

apps/meteor/app/api/server/v1/users.ts

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
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';
33
import { Users, Subscriptions, Sessions } from '@rocket.chat/models';
44
import {
55
isUserCreateParamsPOST,
@@ -425,6 +425,10 @@ API.v1.addRoute(
425425
},
426426
);
427427

428+
type UsersInfoResponseUser = IUser & {
429+
rooms?: Pick<ISubscription, 'rid' | 'name' | 't' | 'roles' | 'unread'>[];
430+
};
431+
428432
const usersInfoEndpoint = API.v1.get(
429433
'users.info',
430434
{
@@ -467,10 +471,31 @@ const usersInfoEndpoint = API.v1.get(
467471
response: {
468472
400: validateBadRequestErrorResponse,
469473
401: validateUnauthorizedErrorResponse,
470-
200: ajv.compile<{ user: IUser; success: true }>({
474+
200: ajv.compile<{ user: UsersInfoResponseUser; success: true }>({
471475
type: 'object',
472476
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+
},
474499
success: { type: 'boolean', enum: [true] },
475500
},
476501
required: ['user', 'success'],

0 commit comments

Comments
 (0)