diff --git a/android/app/build.gradle b/android/app/build.gradle index 60da3b1be538..ebb4c288644f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -150,8 +150,8 @@ android { minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion multiDexEnabled rootProject.ext.multiDexEnabled - versionCode 1001009900 - versionName "1.0.99-0" + versionCode 1001009901 + versionName "1.0.99-1" } splits { abi { diff --git a/ios/NewExpensify/Info.plist b/ios/NewExpensify/Info.plist index 0f57b8a1cf23..1fa761ca323d 100644 --- a/ios/NewExpensify/Info.plist +++ b/ios/NewExpensify/Info.plist @@ -31,7 +31,7 @@ CFBundleVersion - 1.0.99.0 + 1.0.99.1 ITSAppUsesNonExemptEncryption LSApplicationQueriesSchemes diff --git a/ios/NewExpensifyTests/Info.plist b/ios/NewExpensifyTests/Info.plist index b7732f09c710..41865c8e3ff3 100644 --- a/ios/NewExpensifyTests/Info.plist +++ b/ios/NewExpensifyTests/Info.plist @@ -19,6 +19,6 @@ CFBundleSignature ???? CFBundleVersion - 1.0.99.0 + 1.0.99.1 diff --git a/package-lock.json b/package-lock.json index d20990377638..3753427cd35a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.0.99-0", + "version": "1.0.99-1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 4d5ecfad37e2..1b389fac7f56 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "new.expensify", - "version": "1.0.99-0", + "version": "1.0.99-1", "author": "Expensify, Inc.", "homepage": "https://new.expensify.com", "description": "New Expensify is the next generation of Expensify: a reimagination of payments based atop a foundation of chat.", diff --git a/src/libs/API.js b/src/libs/API.js index 1ff70319120c..1f76c5cf9460 100644 --- a/src/libs/API.js +++ b/src/libs/API.js @@ -741,13 +741,13 @@ function User_GetBetas() { /** * @param {Object} parameters - * @param {String} parameters.emailList + * @param {String} parameters.email * @param {Boolean} [parameters.requireCertainty] * @returns {Promise} */ function User_IsFromPublicDomain(parameters) { const commandName = 'User_IsFromPublicDomain'; - requireParameters(['emailList'], parameters, commandName); + requireParameters(['email'], parameters, commandName); return Network.post(commandName, { ...{requireCertainty: true}, ...parameters, diff --git a/src/libs/Navigation/AppNavigator/AuthScreens.js b/src/libs/Navigation/AppNavigator/AuthScreens.js index 79f277401cba..b6bc0b1314f8 100644 --- a/src/libs/Navigation/AppNavigator/AuthScreens.js +++ b/src/libs/Navigation/AppNavigator/AuthScreens.js @@ -184,6 +184,7 @@ class AuthScreens extends React.Component { PersonalDetails.fetchPersonalDetails(); User.getUserDetails(); User.getBetas(); + User.getDomainInfo(); PersonalDetails.fetchLocalCurrency(); fetchAllReports(true, true); fetchCountryCodeByRequestIP(); diff --git a/src/libs/Pusher/EventType.js b/src/libs/Pusher/EventType.js index 357ebd7825a6..713f69b5c128 100644 --- a/src/libs/Pusher/EventType.js +++ b/src/libs/Pusher/EventType.js @@ -7,5 +7,4 @@ export default { REPORT_COMMENT_EDIT: 'reportCommentEdit', REPORT_TOGGLE_PINNED: 'reportTogglePinned', PREFERRED_LOCALE: 'preferredLocale', - ACCOUNT_VALIDATED: 'accountValidated', }; diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index 537060d0b8d2..edaf0f346a2e 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -660,15 +660,6 @@ function updateReportPinnedState(reportID, isPinned) { Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, {isPinned}); } -/** - * Updates isFromPublicDomain in Onyx. - * - * @param {Boolean} isFromPublicDomain - */ -function setIsFromPublicDomain(isFromPublicDomain) { - Onyx.merge(ONYXKEYS.USER, {isFromPublicDomain}); -} - /** * Get the private pusher channel name for a Report. * @@ -750,26 +741,6 @@ function subscribeToUserEvents() { {error, pusherChannelName, eventName: Pusher.TYPE.REPORT_TOGGLE_PINNED}, ); }); - - // Live-update if a user has private domains listed as primary or secondary logins. - Pusher.subscribe(pusherChannelName, Pusher.TYPE.ACCOUNT_VALIDATED, (pushJSON) => { - Log.info( - `[Report] Handled ${Pusher.TYPE.ACCOUNT_VALIDATED} event sent by Pusher`, - false, - {isFromPublicDomain: pushJSON.isFromPublicDomain}, - ); - setIsFromPublicDomain(pushJSON.isFromPublicDomain); - }, false, - () => { - NetworkConnection.triggerReconnectionCallbacks('pusher re-subscribed to private user channel'); - }) - .catch((error) => { - Log.info( - '[Report] Failed to subscribe to Pusher channel', - false, - {error, pusherChannelName, eventName: Pusher.TYPE.ACCOUNT_VALIDATED}, - ); - }); } /** diff --git a/src/libs/actions/User.js b/src/libs/actions/User.js index 14119110d449..799510b06228 100644 --- a/src/libs/actions/User.js +++ b/src/libs/actions/User.js @@ -65,56 +65,6 @@ function getBetas() { }); } -/** - * Fetch the public domain info for the current user (includes secondary logins). - * - * 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. - * - * @param {String} loginList - */ -function getDomainInfo(loginList) { - // 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 we filter out any domains that are in the list of common public domains - const emailList = _.filter(loginList, email => ( - !_.contains(COMMON_PUBLIC_DOMAINS, Str.extractEmailDomain(email)) - )); - - // If there are no emails left, we have a public domain - if (!emailList.length) { - Onyx.merge(ONYXKEYS.USER, {isFromPublicDomain: true}); - return; - } - - // Check the API for the remaining uncommon domains - API.User_IsFromPublicDomain({emailList: emailList.join(',')}) - .then((response) => { - if (response.jsonCode === 200) { - const {isFromPublicDomain} = response; - Onyx.merge(ONYXKEYS.USER, {isFromPublicDomain}); - - // If the user is not on a public domain we'll want to know whether they are on a domain that has - // already provisioned the Expensify card - if (isFromPublicDomain) { - return; - } - - API.User_IsUsingExpensifyCard() - .then(({isUsingExpensifyCard}) => { - Onyx.merge(ONYXKEYS.USER, {isUsingExpensifyCard}); - }); - } else { - // eslint-disable-next-line max-len - console.debug(`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(loginList), RETRY_TIMEOUT); - } - }); -} - /** * Fetches the data needed for user settings */ @@ -140,10 +90,6 @@ function getUserDetails() { const blockedFromConcierge = lodashGet(response, `nameValuePairs.${CONST.NVP.BLOCKED_FROM_CONCIERGE}`, {}); Onyx.merge(ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE, blockedFromConcierge); - // Get domainInfo for user - const emailList = _.map(loginList, userLogin => userLogin.partnerUserID); - getDomainInfo(emailList); - const preferredSkinTone = lodashGet(response, `nameValuePairs.${CONST.NVP.PREFERRED_EMOJI_SKIN_TONE}`, {}); Onyx.merge(ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, getSkinToneEmojiFromIndex(preferredSkinTone).skinTone); @@ -261,6 +207,49 @@ function isBlockedFromConcierge(expiresAt) { return moment().isBefore(moment(expiresAt), 'day'); } +/** + * 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. + */ +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 + API.User_IsFromPublicDomain({email: sessionEmail}) + .then((response) => { + if (response.jsonCode === 200) { + const {isFromPublicDomain} = response; + Onyx.merge(ONYXKEYS.USER, {isFromPublicDomain}); + + // If the user is not on a public domain we'll want to know whether they are on a domain that has + // already provisioned the Expensify card + if (isFromPublicDomain) { + return; + } + + API.User_IsUsingExpensifyCard() + .then(({isUsingExpensifyCard}) => { + Onyx.merge(ONYXKEYS.USER, {isUsingExpensifyCard}); + }); + } else { + // eslint-disable-next-line max-len + console.debug(`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); + } + }); +} + /** * Initialize our pusher subscription to listen for user changes */