2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-06-23 17:24:58 +09:00
|
|
|
import MailChimpList from './mailchimp/mailchimp_list.js';
|
2016-06-23 15:00:58 +09:00
|
|
|
import Users from 'meteor/nova:users';
|
2016-06-15 19:55:59 +09:00
|
|
|
|
2016-02-24 10:27:46 +09:00
|
|
|
function subscribeUserOnProfileCompletion (user) {
|
|
|
|
if (!!Telescope.settings.get('autoSubscribe') && !!Users.getEmail(user)) {
|
2016-11-07 13:00:15 +09:00
|
|
|
try {
|
|
|
|
MailChimpList.add(user, false, function (error, result) {
|
|
|
|
console.log(error);
|
|
|
|
console.log(result);
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.log("// MailChimp Error:")
|
|
|
|
console.log(error)
|
|
|
|
}
|
2016-02-24 10:27:46 +09:00
|
|
|
}
|
|
|
|
return user;
|
|
|
|
}
|
2016-10-07 10:50:21 +02:00
|
|
|
Telescope.callbacks.add("users.profileCompleted.async", subscribeUserOnProfileCompletion);
|