Created
June 15, 2016 10:35
-
-
Save xavxyz/7ab1c2a454534fee6889bdc4703852aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Decouple updating the settings and adding the user to the mailchimplist in case of telescope settings autoSuscribe = true | |
// nova-newsletter/lib/callbacks.js | |
function updateUserNewsletterSettings (user, options) { | |
if (!!Telescope.settings.get('autoSubscribe') && !!user) { | |
user.telescope.newsletter_subscribeToNewsletter = true; | |
} | |
return user; | |
} | |
Telescope.callbacks.add("onCreateUser", updateUserNewsletterSettings); | |
function subscribeUserOnProfileCompletion (user) { | |
if (!!Telescope.settings.get('autoSubscribe') && !!Users.getEmail(user)) { | |
Meteor.call('newsletter.addEmail', user, false, function (error, result) { | |
console.log(error); | |
console.log(result); | |
}); | |
} | |
return user; | |
} | |
Telescope.callbacks.add("profileCompletedAsync", subscribeUserOnProfileCompletion); | |
// Tweak addEmail method so we can't disable the confirm email in parameters (was true by default) | |
// nova-newsletter/lib/server/mailchimp.js | |
// L35 | |
'newsletter.addEmail'(email, confirm = true) { | |
try { | |
return MailChimpList.add(email, confirm); | |
} catch (error) { | |
throw new Meteor.Error(500, error.message); | |
} | |
} | |
// If the user is already "marked" as subscribe, don't update his profile | |
// nova-newsletter/lib/server/mailchimp.js | |
// L133-136 | |
// mark user as subscribed | |
if (!!user && !Users.getSetting(user, 'newsletter_subscribeToNewsletter')) { | |
Users.setSetting(user, 'newsletter_subscribeToNewsletter', true); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Telescope Slack discussion, check on user issue, starts around here : https://telescopeapp.slack.com/archives/general/p1465984120000353