Skip to content

Commit

Permalink
Chore: Migrate REST API - addUsersToRoom to Typescript (#3884)
Browse files Browse the repository at this point in the history
* Chore: Migrate REST API - addUsersToRoom to Typescript

* Update app/lib/rocketchat/services/restApi.ts

Co-authored-by: Gleidson Daniel Silva <gleidson10daniel@hotmail.com>

* minor tweak

Co-authored-by: Gleidson Daniel Silva <gleidson10daniel@hotmail.com>
  • Loading branch information
reinaldonetof and dnlsilva authored Mar 15, 2022
1 parent db5c7d9 commit de8a7f1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/definitions/rest/v1/channels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export type ChannelsEndpoints = {
};
'channels.roles': {
GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] };
};
};
'channels.messages': {
GET: (params: {
roomId: IServerRoom['_id'];
Expand Down
2 changes: 1 addition & 1 deletion app/definitions/rest/v1/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export type GroupsEndpoints = {
};
'groups.roles': {
GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] };
};
};
'groups.messages': {
GET: (params: {
roomId: IServerRoom['_id'];
Expand Down
6 changes: 0 additions & 6 deletions app/lib/rocketchat/rocketchat.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,6 @@ const RocketChat = {
// RC 3.1.0
return this.post('users.2fa.sendEmailCode', { emailOrUsername: username });
},
addUsersToRoom(rid) {
let { users } = reduxStore.getState().selectedUsers;
users = users.map(u => u.name);
// RC 0.51.0
return this.methodCallWrapper('addUsersToRoom', { rid, users });
},
hasRole(role) {
const shareUser = reduxStore.getState().share.user;
const loginUser = reduxStore.getState().login.user;
Expand Down
7 changes: 7 additions & 0 deletions app/lib/rocketchat/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,13 @@ export const useInviteToken = (token: string): any =>
// @ts-ignore
sdk.post('useInviteToken', { token });

export const addUsersToRoom = (rid: string): Promise<boolean> => {
const { users: selectedUsers } = reduxStore.getState().selectedUsers;
const users = selectedUsers.map(u => u.name);
// RC 0.51.0
return sdk.methodCallWrapper('addUsersToRoom', { rid, users });
};

export const emitTyping = (room: IRoom, typing = true) => {
const { login, settings } = reduxStore.getState();
const { UI_Use_Real_Name } = settings;
Expand Down

0 comments on commit de8a7f1

Please sign in to comment.