mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 18:11:40 -05:00
45 lines
No EOL
956 B
JavaScript
45 lines
No EOL
956 B
JavaScript
Meteor.methods({
|
|
addNotification: function(event, properties, userToNotify, userDoingAction){
|
|
// console.log('adding new notification for:'+getDisplayName(userToNotify)+', for event:'+event);
|
|
// console.log(userToNotify);
|
|
// console.log(userDoingAction);
|
|
// console.log(properties);
|
|
if(userToNotify._id!=userDoingAction._id){
|
|
// make sure we don't notify people of their own actions
|
|
Meteor.users.update(
|
|
{_id: userToNotify._id},
|
|
{$push:
|
|
{
|
|
'notifications': {
|
|
timestamp: new Date().getTime(),
|
|
event: event,
|
|
properties: properties,
|
|
read: false
|
|
}
|
|
}
|
|
},
|
|
function(error, result){
|
|
if(error){
|
|
console.log(error);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
},
|
|
clearNotifications: function(user){
|
|
Meteor.users.update(
|
|
{_id: user._id},
|
|
{$pull:
|
|
{
|
|
'notifications': {}
|
|
}
|
|
},
|
|
function(error, result){
|
|
if(error){
|
|
console.log(error);
|
|
|
|
}
|
|
}
|
|
);
|
|
}
|
|
}); |