Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/definitions/IRole.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,14 @@ export interface IRole {
}

export type TRoleModel = IRole & Model;

// For rest/v1/ 'groups.roles' and 'channels.roles'
export interface IGetRoomRoles {
_id: string;
rid: string;
u: {
_id: string;
username: string;
};
roles: string[];
}
4 changes: 4 additions & 0 deletions app/definitions/rest/v1/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ITeam } from '../../ITeam';
import type { IMessageFromServer } from '../../IMessage';
import type { IServerRoom } from '../../IRoom';
import type { IUser } from '../../IUser';
import { IGetRoomRoles } from '../../IRole';
import { IServerAttachment } from '../../IAttachment';

export type ChannelsEndpoints = {
Expand Down Expand Up @@ -96,6 +97,9 @@ export type ChannelsEndpoints = {
'channels.removeLeader': {
POST: (params: { roomId: string; userId: string }) => {};
};
'channels.roles': {
GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] };
};
'channels.messages': {
GET: (params: {
roomId: IServerRoom['_id'];
Expand Down
4 changes: 4 additions & 0 deletions app/definitions/rest/v1/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ITeam } from '../../ITeam';
import type { IMessageFromServer } from '../../IMessage';
import type { IServerRoom } from '../../IRoom';
import type { IUser } from '../../IUser';
import { IGetRoomRoles } from '../../IRole';
import { IServerAttachment } from '../../IAttachment';

export type GroupsEndpoints = {
Expand Down Expand Up @@ -72,6 +73,9 @@ export type GroupsEndpoints = {
'groups.leave': {
POST: (params: { roomId: string }) => {};
};
'groups.roles': {
GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] };
};
'groups.messages': {
GET: (params: {
roomId: IServerRoom['_id'];
Expand Down
2 changes: 1 addition & 1 deletion app/lib/rocketchat/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ const RocketChat = {
...(filter && { filter })
};
// RC 3.16.0
const result = await this.sdk.get(`${this.roomTypeToApiType(roomType)}.members`, params);
const result = await sdk.get(`${this.roomTypeToApiType(roomType)}.members`, params);
return result?.members;
}
// RC 0.42.0
Expand Down
7 changes: 4 additions & 3 deletions app/lib/rocketchat/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,10 +570,11 @@ export const getSingleMessage = (msgId: string) =>
// RC 0.47.0
sdk.get('chat.getMessage', { msgId });

export const getRoomRoles = (roomId: string, type: SubscriptionType): any =>
export const getRoomRoles = (
roomId: string,
type: SubscriptionType.CHANNEL | SubscriptionType.GROUP | SubscriptionType.OMNICHANNEL
) =>
// RC 0.65.0
// TODO: missing definitions from server
// @ts-ignore
sdk.get(`${roomTypeToApiType(type)}.roles`, { roomId });

export const getAvatarSuggestion = (): Promise<IAvatarSuggestion> =>
Expand Down
3 changes: 2 additions & 1 deletion app/views/RoomMembersView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ class RoomMembersView extends React.Component<IRoomMembersViewProps, IRoomMember
fetchRoomMembersRoles = async () => {
try {
const { room } = this.state;
const result = await RocketChat.getRoomRoles(room.rid, room.t);
const type = room.t as SubscriptionType.CHANNEL | SubscriptionType.GROUP | SubscriptionType.OMNICHANNEL;
const result = await RocketChat.getRoomRoles(room.rid, type);
if (result?.success) {
this.roomRoles = result.roles;
}
Expand Down