@@ -4,6 +4,7 @@ import { isPrivateRoom, isPublicRoom } from '@rocket.chat/core-typings';
44import { Messages , Rooms , Users , Uploads , Subscriptions } from '@rocket.chat/models' ;
55import type { Notifications } from '@rocket.chat/rest-typings' ;
66import {
7+ ajv ,
78 isGETRoomsNameExists ,
89 isRoomsImagesProps ,
910 isRoomsMuteUnmuteUserProps ,
@@ -23,6 +24,7 @@ import * as dataExport from '../../../../server/lib/dataExport';
2324import { eraseRoom } from '../../../../server/lib/eraseRoom' ;
2425import { findUsersOfRoomOrderedByRole } from '../../../../server/lib/findUsersOfRoomOrderedByRole' ;
2526import { openRoom } from '../../../../server/lib/openRoom' ;
27+ import type { RoomRoles } from '../../../../server/lib/roles/getRoomRoles' ;
2628import { hideRoomMethod } from '../../../../server/methods/hideRoom' ;
2729import { muteUserInRoom } from '../../../../server/methods/muteUserInRoom' ;
2830import { toggleFavoriteMethod } from '../../../../server/methods/toggleFavorite' ;
@@ -37,12 +39,14 @@ import { sendFileMessage } from '../../../file-upload/server/methods/sendFileMes
3739import { syncRolePrioritiesForRoomIfRequired } from '../../../lib/server/functions/syncRolePrioritiesForRoomIfRequired' ;
3840import { executeArchiveRoom } from '../../../lib/server/methods/archiveRoom' ;
3941import { cleanRoomHistoryMethod } from '../../../lib/server/methods/cleanRoomHistory' ;
42+ import { executeGetRoomRoles } from '../../../lib/server/methods/getRoomRoles' ;
4043import { leaveRoomMethod } from '../../../lib/server/methods/leaveRoom' ;
4144import { executeUnarchiveRoom } from '../../../lib/server/methods/unarchiveRoom' ;
4245import { applyAirGappedRestrictionsValidation } from '../../../license/server/airGappedRestrictionsWrapper' ;
4346import type { NotificationFieldType } from '../../../push-notifications/server/methods/saveNotificationSettings' ;
4447import { saveNotificationSettingsMethod } from '../../../push-notifications/server/methods/saveNotificationSettings' ;
4548import { settings } from '../../../settings/server' ;
49+ import type { ExtractRoutesFromAPI } from '../ApiClass' ;
4650import { API } from '../api' ;
4751import { composeRoomWithLastMessage } from '../helpers/composeRoomWithLastMessage' ;
4852import { getPaginationItems } from '../helpers/getPaginationItems' ;
@@ -1005,3 +1009,62 @@ API.v1.addRoute(
10051009 } ,
10061010 } ,
10071011) ;
1012+
1013+ const isRoomGetRolesPropsSchema = {
1014+ type : 'object' ,
1015+ properties : {
1016+ rid : { type : 'string' } ,
1017+ } ,
1018+ additionalProperties : false ,
1019+ required : [ 'rid' ] ,
1020+ } ;
1021+ export const roomEndpoints = API . v1 . get (
1022+ 'rooms.roles' ,
1023+ {
1024+ authRequired : true ,
1025+ query : ajv . compile < {
1026+ rid : string ;
1027+ } > ( isRoomGetRolesPropsSchema ) ,
1028+ response : {
1029+ 200 : ajv . compile < {
1030+ roles : RoomRoles [ ] ;
1031+ } > ( {
1032+ type : 'object' ,
1033+ properties : {
1034+ roles : {
1035+ type : 'array' ,
1036+ items : {
1037+ type : 'object' ,
1038+ properties : {
1039+ rid : { type : 'string' } ,
1040+ u : {
1041+ type : 'object' ,
1042+ properties : { _id : { type : 'string' } , username : { type : 'string' } } ,
1043+ required : [ '_id' , 'username' ] ,
1044+ } ,
1045+ roles : { type : 'array' , items : { type : 'string' } } ,
1046+ } ,
1047+ required : [ 'rid' , 'u' , 'roles' ] ,
1048+ } ,
1049+ } ,
1050+ } ,
1051+ required : [ 'roles' ] ,
1052+ } ) ,
1053+ } ,
1054+ } ,
1055+ async function ( ) {
1056+ const { rid } = this . queryParams ;
1057+ const roles = await executeGetRoomRoles ( rid , this . userId ) ;
1058+
1059+ return API . v1 . success ( {
1060+ roles,
1061+ } ) ;
1062+ } ,
1063+ ) ;
1064+
1065+ type RoomEndpoints = ExtractRoutesFromAPI < typeof roomEndpoints > ;
1066+
1067+ declare module '@rocket.chat/rest-typings' {
1068+ // eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
1069+ interface Endpoints extends RoomEndpoints { }
1070+ }
0 commit comments