From 0023f0e1956ae0012d759ddad4d45c1887ae8e79 Mon Sep 17 00:00:00 2001 From: Alex Junior Date: Tue, 15 Mar 2022 21:29:48 -0300 Subject: [PATCH] Chore: Migrate REST API - sendEmailCode to Typescript (#3891) --- app/lib/rocketchat/rocketchat.js | 9 +++++---- app/lib/rocketchat/services/restApi.ts | 7 +++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/lib/rocketchat/rocketchat.js b/app/lib/rocketchat/rocketchat.js index eab89d83..24aa2ccc 100644 --- a/app/lib/rocketchat/rocketchat.js +++ b/app/lib/rocketchat/rocketchat.js @@ -365,10 +365,11 @@ const RocketChat = { methodCall(...args) { return sdk.methodCall(...args); }, - sendEmailCode() { - const { username } = reduxStore.getState().login.user; - // 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; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 27b3baef..071976a8 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -5,6 +5,7 @@ import { IRoom, IRoomNotifications, SubscriptionType, + IUser, TRocketChat } from '../../../definitions'; import { TParams } from '../../../definitions/ILivechatEditView'; @@ -805,3 +806,9 @@ export const editMessage = async (message: IMessage) => { // RC 0.49.0 return sdk.post('chat.update', { roomId: rid, msgId: message.id, text: msg }); }; + +export const sendEmailCode = () => { + const { username } = reduxStore.getState().login.user as IUser; + // RC 3.1.0 + return sdk.post('users.2fa.sendEmailCode', { emailOrUsername: username }); +};