Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA] Add check for isUsingExpensifyCard #3664

Merged
merged 2 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/libs/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,13 @@ function GetCurrencyList() {
return Mobile_GetConstants({data: ['currencyList']});
}

/**
* @returns {Promise}
*/
function User_IsUsingExpensifyCard() {
return Network.post('User_IsUsingExpensifyCard', {});
}

/**
* @param {Object} parameters
* @param {String} [parameters.type]
Expand Down Expand Up @@ -1001,6 +1008,7 @@ export {
User_SignUp,
User_GetBetas,
User_IsFromPublicDomain,
User_IsUsingExpensifyCard,
User_ReopenAccount,
User_SecondaryLogin_Send,
User_UploadAvatar,
Expand Down
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class AuthScreens extends React.Component {
PersonalDetails.fetchPersonalDetails();
User.getUserDetails();
User.getBetas();
User.getPublicDomainInfo();
User.getDomainInfo();
PersonalDetails.fetchCurrencyPreferences();
fetchAllReports(true, true);
fetchCountryCodeByRequestIP();
Expand Down
17 changes: 14 additions & 3 deletions src/libs/actions/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ function validateLogin(accountID, validateCode) {
* 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 getPublicDomainInfo() {
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;
Expand All @@ -198,10 +198,21 @@ function getPublicDomainInfo() {
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;
}
Comment on lines +204 to +206
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do public domains get excluded here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK only users with private domains as their primary login are eligible for the Expensify card. So, if they are on a public domain we don't need to know if they are using the Expensify card already since we'll show them alternative marketing copy that instructs them update their login first.


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(getPublicDomainInfo, RETRY_TIMEOUT);
setTimeout(getDomainInfo, RETRY_TIMEOUT);
}
});
}
Expand All @@ -214,5 +225,5 @@ export {
setExpensifyNewsStatus,
setSecondaryLogin,
validateLogin,
getPublicDomainInfo,
getDomainInfo,
};