From de8a7f1ce064a264ffb6bec1e04ee67c22d4a9c8 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Mon, 14 Mar 2022 21:29:48 -0300 Subject: [PATCH] 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 * minor tweak Co-authored-by: Gleidson Daniel Silva --- app/definitions/rest/v1/channels.ts | 2 +- app/definitions/rest/v1/groups.ts | 2 +- app/lib/rocketchat/rocketchat.js | 6 ------ app/lib/rocketchat/services/restApi.ts | 7 +++++++ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/definitions/rest/v1/channels.ts b/app/definitions/rest/v1/channels.ts index d3b0a966e..8bca5f1d6 100644 --- a/app/definitions/rest/v1/channels.ts +++ b/app/definitions/rest/v1/channels.ts @@ -99,7 +99,7 @@ export type ChannelsEndpoints = { }; 'channels.roles': { GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] }; - }; + }; 'channels.messages': { GET: (params: { roomId: IServerRoom['_id']; diff --git a/app/definitions/rest/v1/groups.ts b/app/definitions/rest/v1/groups.ts index ff329f2f0..d22dabfc5 100644 --- a/app/definitions/rest/v1/groups.ts +++ b/app/definitions/rest/v1/groups.ts @@ -75,7 +75,7 @@ export type GroupsEndpoints = { }; 'groups.roles': { GET: (params: { roomId: string }) => { roles: IGetRoomRoles[] }; - }; + }; 'groups.messages': { GET: (params: { roomId: IServerRoom['_id']; diff --git a/app/lib/rocketchat/rocketchat.js b/app/lib/rocketchat/rocketchat.js index 451d9ea6b..394bb4833 100644 --- a/app/lib/rocketchat/rocketchat.js +++ b/app/lib/rocketchat/rocketchat.js @@ -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; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index e48415987..981f49615 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -753,6 +753,13 @@ export const useInviteToken = (token: string): any => // @ts-ignore sdk.post('useInviteToken', { token }); +export const addUsersToRoom = (rid: string): Promise => { + 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;