Chore: Migrate REST API - addUsersToRoom to Typescript (#3884)

* 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>
This commit is contained in:
Reinaldo Neto 2022-03-14 21:29:48 -03:00 committed by GitHub
parent db5c7d94aa
commit de8a7f1ce0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 8 deletions

View File

@ -99,7 +99,7 @@ export type ChannelsEndpoints = {
}; };
'channels.roles': { 'channels.roles': {
GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] }; GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] };
}; };
'channels.messages': { 'channels.messages': {
GET: (params: { GET: (params: {
roomId: IServerRoom['_id']; roomId: IServerRoom['_id'];

View File

@ -75,7 +75,7 @@ export type GroupsEndpoints = {
}; };
'groups.roles': { 'groups.roles': {
GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] }; GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] };
}; };
'groups.messages': { 'groups.messages': {
GET: (params: { GET: (params: {
roomId: IServerRoom['_id']; roomId: IServerRoom['_id'];

View File

@ -377,12 +377,6 @@ const RocketChat = {
// RC 3.1.0 // RC 3.1.0
return this.post('users.2fa.sendEmailCode', { emailOrUsername: username }); 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) { hasRole(role) {
const shareUser = reduxStore.getState().share.user; const shareUser = reduxStore.getState().share.user;
const loginUser = reduxStore.getState().login.user; const loginUser = reduxStore.getState().login.user;

View File

@ -753,6 +753,13 @@ export const useInviteToken = (token: string): any =>
// @ts-ignore // @ts-ignore
sdk.post('useInviteToken', { token }); 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) => { export const emitTyping = (room: IRoom, typing = true) => {
const { login, settings } = reduxStore.getState(); const { login, settings } = reduxStore.getState();
const { UI_Use_Real_Name } = settings; const { UI_Use_Real_Name } = settings;