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

GH-1936 & GH-1920 Remove email opt-in from account creation in panel and hub #495

Merged
merged 8 commits into from Feb 14, 2020

Remove opt into emails entirely

  • Loading branch information
benstrumeyer committed Feb 11, 2020
commit 28d6793efdb0a051493367b913b3b5dd35d69bbb
@@ -26,8 +26,6 @@ import {
GET_USER_FAIL,
GET_USER_SETTINGS_SUCCESS,
GET_USER_SETTINGS_FAIL,
OPT_INTO_PROMOTIONS_FAIL,
OPT_INTO_PROMOTIONS_SUCCESS,
GET_USER_SUBSCRIPTION_DATA_FAIL,
GET_USER_SUBSCRIPTION_DATA_SUCCESS
} from './AccountConstants';
@@ -191,26 +189,3 @@ export const resetPassword = email => dispatch => (
});
})
);

export const optIntoPromotions = () => dispatch => (
sendMessageInPromise('account.promotions').then((res) => {
const { errors } = res;
if (errors) {
dispatch({
type: OPT_INTO_PROMOTIONS_FAIL,
payload: { errors },
});
return false;
}
dispatch({ type: OPT_INTO_PROMOTIONS_SUCCESS });
return true;
}).catch((err) => {
const errors = [{ title: err.toString(), detail: err.toString() }];
dispatch({
type: OPT_INTO_PROMOTIONS_FAIL,
payload: {
errors,
},
});
})
);
@@ -33,10 +33,6 @@ export const GET_USER_FAIL = 'GET_USER_FAIL';
export const GET_USER_SETTINGS_SUCCESS = 'GET_USER_SETTINGS_SUCCESS';
export const GET_USER_SETTINGS_FAIL = 'GET_USER_SETTINGS_FAIL';

// Opt into Promotions
export const OPT_INTO_PROMOTIONS_FAIL = 'OPT_INTO_PROMOTIONS_FAIL';
export const OPT_INTO_PROMOTIONS_SUCCESS = 'OPT_INTO_PROMOTIONS_SUCCESS';

// Update Subscription Data
export const GET_USER_SUBSCRIPTION_DATA_FAIL = 'GET_USER_SUBSCRIPTION_DATA_FAIL';
export const GET_USER_SUBSCRIPTION_DATA_SUCCESS = 'GET_USER_SUBSCRIPTION_DATA_SUCCESS';
@@ -138,7 +138,6 @@ class CreateAccountViewContainer extends Component {
});
this.props.actions.register(email, confirmEmail, firstName, lastName, password).then((success) => {
if (success) {
this.props.actions.optIntoPromotions();
this.props.actions.getUser();
this.props.actions.setToast({
toastMessage: t('hub_create_account_toast_success'),
@@ -207,7 +206,6 @@ CreateAccountViewContainer.propTypes = {
setToast: PropTypes.func.isRequired,
register: PropTypes.func.isRequired,
getUser: PropTypes.func.isRequired,
optIntoPromotions: PropTypes.func.isRequired,
}).isRequired,
};

@@ -15,7 +15,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';

import CreateAccountViewContainer from './CreateAccountViewContainer';
import { register, getUser, optIntoPromotions } from '../../../Account/AccountActions';
import { register, getUser } from '../../../Account/AccountActions';
import { setToast } from '../AppView/AppViewActions';

/**
@@ -37,7 +37,6 @@ const mapDispatchToProps = dispatch => ({
setToast,
register,
getUser,
optIntoPromotions,
}), dispatch),
});

@@ -118,7 +118,6 @@ class CreateAccount extends React.Component {
this.props.actions.register(email, confirmEmail, firstName, lastName, password).then((success) => {
this.setState({ loading: false });
if (success) {
this.props.actions.optIntoPromotions();
new RSVP.Promise((resolve) => {
this.props.actions.getUser()
.then(() => resolve())
@@ -15,7 +15,7 @@ import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import CreateAccount from '../components/CreateAccount';
import * as actions from '../actions/PanelActions'; // get shared actions from Panel
import { register, getUser, optIntoPromotions } from '../../Account/AccountActions';
import { register, getUser } from '../../Account/AccountActions';

/**
* Map redux store state properties to CreateAccount component own properties.
@@ -38,7 +38,7 @@ const mapStateToProps = state => Object.assign({}, state.createAccount, {
* @param {Object} ownProps CreateAccount component own props
* @return {function} to be used as an argument in redux connect call
*/
const mapDispatchToProps = dispatch => ({ actions: bindActionCreators(Object.assign(actions, { register, getUser, optIntoPromotions }), dispatch) });
const mapDispatchToProps = dispatch => ({ actions: bindActionCreators(Object.assign(actions, { register, getUser }), dispatch) });
/**
* Connects CreateAccount component to the Redux store.
* @memberOf PanelContainers
@@ -896,15 +896,6 @@ function onMessageHandler(request, sender, callback) {
});
return true;
}
if (name === 'account.promotions') {
account.updateEmailPreferences().then((success) => {
callback(success);
}).catch((err) => {
callback({ errors: _getJSONAPIErrorsObject(err) });
log('UPDATE PROMOTIONS FAIL', err);
});
return true;
}
if (name === 'update_database') {
checkLibraryVersion().then((result) => {
callback(result);
@@ -215,19 +215,6 @@ class Account {
})
)

updateEmailPreferences = () => (
this._getUserID().then(userID => (
api.update('email_preferences', {
type: 'email_preferences',
id: userID,
attributes: {
updates: true,
promotions: true,
}
})
))
)

sendValidateAccountEmail = () => (
this._getUserID()
.then(userID => fetch(`${AUTH_SERVER}/api/v2/send_email/validate_account/${userID}`))
ProTip! Use n and p to navigate between commits in a pull request.