2015-08-13 11:32:41 +09:00
|
|
|
Meteor.startup(function () {
|
|
|
|
Herald.collection._ensureIndex({userId: 1, "media.email.send": 1, "media.email.sent": 1});
|
|
|
|
});
|
|
|
|
|
2015-04-22 07:50:11 +09:00
|
|
|
getUnsubscribeLink = function(user){
|
2015-05-06 12:16:50 +09:00
|
|
|
return Telescope.utils.getRouteUrl('unsubscribe', {hash: user.telescope.emailHash});
|
2015-04-22 07:50:11 +09:00
|
|
|
};
|
|
|
|
|
|
|
|
Meteor.methods({
|
|
|
|
unsubscribeUser : function(hash){
|
2015-07-10 11:40:11 +09:00
|
|
|
check(hash, String);
|
2015-04-22 07:50:11 +09:00
|
|
|
// TO-DO: currently, if you have somebody's email you can unsubscribe them
|
|
|
|
// A user-specific salt should be added to the hashing method to prevent this
|
2015-05-06 12:16:50 +09:00
|
|
|
var user = Meteor.users.findOne({"telescope.emailHash": hash});
|
2015-04-22 07:50:11 +09:00
|
|
|
if(user){
|
2015-05-01 18:22:00 +02:00
|
|
|
Meteor.users.update(user._id, {
|
2015-04-22 07:50:11 +09:00
|
|
|
$set: {
|
|
|
|
'profile.notifications.users' : 0,
|
|
|
|
'profile.notifications.posts' : 0,
|
|
|
|
'profile.notifications.comments' : 0,
|
|
|
|
'profile.notifications.replies' : 0
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|