From 307ae1295f2db21a544230c1da3db102c86bad1d Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Mon, 14 Mar 2022 11:56:49 -0300 Subject: [PATCH] Chore: Migrate REST API - e2eResetOwnKey to Typescript (#3888) * Chore: Migrate REST API - e2eResetOwnKey to Typescript * Update app/lib/rocketchat/services/restApi.ts Co-authored-by: Gleidson Daniel Silva --- app/definitions/IRocketChat.ts | 2 +- app/lib/rocketchat/rocketchat.js | 7 ------- app/lib/rocketchat/services/restApi.ts | 11 ++++++++++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/definitions/IRocketChat.ts b/app/definitions/IRocketChat.ts index e9401067b..6fb88a263 100644 --- a/app/definitions/IRocketChat.ts +++ b/app/definitions/IRocketChat.ts @@ -1,6 +1,6 @@ import rocketchat from '../lib/rocketchat'; -type TRocketChat = typeof rocketchat; +export type TRocketChat = typeof rocketchat; export interface IRocketChat extends TRocketChat { closeListener: any; diff --git a/app/lib/rocketchat/rocketchat.js b/app/lib/rocketchat/rocketchat.js index 16527a0b9..b0b951d73 100644 --- a/app/lib/rocketchat/rocketchat.js +++ b/app/lib/rocketchat/rocketchat.js @@ -196,13 +196,6 @@ const RocketChat = { } return result; }, - e2eResetOwnKey() { - this.unsubscribeRooms(); - - // RC 0.72.0 - return this.methodCallWrapper('e2e.resetOwnE2EKey'); - }, - loginTOTP, loginWithPassword, loginOAuthOrSso, diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 6474eda16..43d414a88 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -1,7 +1,7 @@ import sdk from './sdk'; import { TEAM_TYPE } from '../../../definitions/ITeam'; import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType'; -import { SubscriptionType, INotificationPreferences, IRoomNotifications, IMessage } from '../../../definitions'; +import { SubscriptionType, INotificationPreferences, IRoomNotifications, TRocketChat, IMessage } from '../../../definitions'; import { ISpotlight } from '../../../definitions/ISpotlight'; import { IAvatarSuggestion, IParams } from '../../../definitions/IProfileViewInterfaces'; import { Encryption } from '../../encryption'; @@ -744,6 +744,15 @@ export const useInviteToken = (token: string): any => // @ts-ignore sdk.post('useInviteToken', { token }); +export function e2eResetOwnKey(this: TRocketChat): Promise { + // {} when TOTP is enabled + // TODO: remove this + this.unsubscribeRooms(); + + // RC 0.72.0 + return sdk.methodCallWrapper('e2e.resetOwnE2EKey'); +} + export const editMessage = async (message: IMessage) => { const { rid, msg } = await Encryption.encryptMessage(message); // RC 0.49.0