2017-03-23 16:27:59 +09:00
|
|
|
import Users from 'meteor/vulcan:users';
|
|
|
|
import { addCallback, getSetting } from 'meteor/vulcan:core';
|
2017-04-11 10:49:54 +09:00
|
|
|
import Newsletters from '../modules/collection.js';
|
2016-06-15 19:55:59 +09:00
|
|
|
|
2016-02-24 10:27:46 +09:00
|
|
|
function subscribeUserOnProfileCompletion (user) {
|
2016-12-12 15:00:56 +09:00
|
|
|
if (!!getSetting('autoSubscribe') && !!Users.getEmail(user)) {
|
2016-11-07 13:00:15 +09:00
|
|
|
try {
|
2017-04-20 19:06:59 +09:00
|
|
|
Newsletters.subscribeUser(user, false);
|
2016-11-07 13:00:15 +09:00
|
|
|
} catch (error) {
|
2017-04-11 10:49:54 +09:00
|
|
|
console.log("// Newsletter Error:") // eslint-disable-line
|
2016-12-08 23:48:16 +01:00
|
|
|
console.log(error) // eslint-disable-line
|
2016-11-07 13:00:15 +09:00
|
|
|
}
|
2016-02-24 10:27:46 +09:00
|
|
|
}
|
|
|
|
return user;
|
|
|
|
}
|
2016-12-13 11:40:24 +09:00
|
|
|
addCallback("users.profileCompleted.async", subscribeUserOnProfileCompletion);
|