From 7b260eb9d4456a84f87c96151ffce17db1b6f986 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 7 Jul 2022 11:07:24 -0600 Subject: [PATCH 1/3] rm User_IsFromPublicDomain --- src/libs/actions/User.js | 35 ++++------------------------------- src/libs/deprecatedAPI.js | 16 ---------------- 2 files changed, 4 insertions(+), 47 deletions(-) diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 148d5cbfa40e..b132ed59035a 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -267,39 +267,12 @@ function isBlockedFromConcierge(blockedFromConcierge) { } /** - * Fetch the public domain info for the current user. - * - * This API is a bit weird in that it sometimes depends on information being cached in bedrock. - * If the info for the domain is not in bedrock, then it creates an asynchronous bedrock job to gather domain info. - * If that happens, this function will automatically retry itself in 10 minutes. + * Fetch whether the user has the Expensify card enabled. */ function getDomainInfo() { - // If this command fails, we'll retry again in 10 minutes, - // arbitrarily chosen giving Bedrock time to resolve the ClearbitCheckPublicEmail job for this email. - const RETRY_TIMEOUT = 600000; - - // First check list of common public domains - if (_.contains(COMMON_PUBLIC_DOMAINS, sessionEmail)) { - Onyx.merge(ONYXKEYS.USER, {isFromPublicDomain: true}); - return; - } - - // If it is not a common public domain, check the API - DeprecatedAPI.User_IsFromPublicDomain({email: sessionEmail}) - .then((response) => { - if (response.jsonCode === 200) { - const {isFromPublicDomain} = response; - Onyx.merge(ONYXKEYS.USER, {isFromPublicDomain}); - - DeprecatedAPI.User_IsUsingExpensifyCard() - .then(({isUsingExpensifyCard}) => { - Onyx.merge(ONYXKEYS.USER, {isUsingExpensifyCard}); - }); - } else { - // eslint-disable-next-line max-len - Log.info(`Command User_IsFromPublicDomain returned error code: ${response.jsonCode}. Most likely, this means that the domain ${Str.extractEmail(sessionEmail)} is not in the bedrock cache. Retrying in ${RETRY_TIMEOUT / 1000 / 60} minutes`); - setTimeout(getDomainInfo, RETRY_TIMEOUT); - } + DeprecatedAPI.User_IsUsingExpensifyCard() + .then(({isUsingExpensifyCard}) => { + Onyx.merge(ONYXKEYS.USER, {isUsingExpensifyCard}); }); } diff --git a/src/libs/deprecatedAPI.js b/src/libs/deprecatedAPI.js index 24a9c3e9c73c..1ccc2c229e35 100644 --- a/src/libs/deprecatedAPI.js +++ b/src/libs/deprecatedAPI.js @@ -456,21 +456,6 @@ function User_GetBetas() { return Network.post('User_GetBetas'); } -/** - * @param {Object} parameters - * @param {String} parameters.email - * @param {Boolean} [parameters.requireCertainty] - * @returns {Promise} - */ -function User_IsFromPublicDomain(parameters) { - const commandName = 'User_IsFromPublicDomain'; - requireParameters(['email'], parameters, commandName); - return Network.post(commandName, { - ...{requireCertainty: true}, - ...parameters, - }); -} - /** * @param {Object} parameters * @param {String} parameters.email @@ -953,7 +938,6 @@ export { User_SignUp, User_Delete, User_GetBetas, - User_IsFromPublicDomain, User_IsUsingExpensifyCard, User_ReopenAccount, User_SecondaryLogin_Send, From 26a68eb806b139e650a0e64ff202fbdf1f73630b Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 7 Jul 2022 11:20:18 -0600 Subject: [PATCH 2/3] fix lint --- src/libs/actions/User.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index b132ed59035a..e47f64ee7e9f 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -1,8 +1,6 @@ import _ from 'underscore'; import lodashGet from 'lodash/get'; import Onyx from 'react-native-onyx'; -import Str from 'expensify-common/lib/str'; -import {PUBLIC_DOMAINS as COMMON_PUBLIC_DOMAINS} from 'expensify-common/lib/CONST'; import moment from 'moment'; import ONYXKEYS from '../../ONYXKEYS'; import * as DeprecatedAPI from '../deprecatedAPI'; From adf71d39e6e4e6c5855e17fc93328260b2db6058 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 7 Jul 2022 11:24:46 -0600 Subject: [PATCH 3/3] rm unused sessionEmail --- src/libs/actions/User.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index e47f64ee7e9f..f316ac00fdc0 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -23,13 +23,11 @@ import * as SequentialQueue from '../Network/SequentialQueue'; import PusherUtils from '../PusherUtils'; let sessionAuthToken = ''; -let sessionEmail = ''; let currentUserAccountID = ''; Onyx.connect({ key: ONYXKEYS.SESSION, callback: (val) => { sessionAuthToken = lodashGet(val, 'authToken', ''); - sessionEmail = lodashGet(val, 'email', ''); currentUserAccountID = lodashGet(val, 'accountID', ''); }, });