Notifications = new Meteor.Collection('notifications'); // Notifications = new Meteor.Collection("notifications", { // schema: new SimpleSchema({ // properties: { // type: Object // }, // event: { // type: String // }, // read: { // type: Boolean // }, // createdAt: { // type: Date // }, // userId: { // type: "???" // } // }) // }); Notifications.allow({ insert: function(userId, doc){ // new notifications can only be created via a Meteor method return false; } , update: canEditById , remove: canEditById }); getNotificationContents = function(notification, context){ // the same notifications can be displayed in multiple contexts: on-site in the sidebar, sent by email, etc. var event = notification.event, p = notification.properties, context = typeof context === 'undefined' ? 'sidebar' : context, userToNotify = Meteor.users.findOne(notification.userId); switch(event){ case 'newReply': var n = { subject: 'Someone replied to your comment on "'+p.postTitle+'"', text: p.commentAuthorName+' has replied to your comment on "'+p.postTitle+'": '+getPostCommentUrl(p.postId, p.commentId), html: '
'+p.commentAuthorName+' has replied to your comment on "'+p.postTitle+'"
' }; if(context == 'email') n.html += ''+p.commentExcerpt+'
Read more'; break; case 'newComment': var n = { subject: 'A new comment on your post "'+p.postTitle+'"', text: 'You have a new comment by '+p.commentAuthorName+' on your post "'+p.postTitle+'": '+getPostCommentUrl(p.postId, p.commentId), html: ''+p.commentAuthorName+' left a new comment on your post "'+p.postTitle+'"
' }; if(context == 'email') n.html += ''+p.commentExcerpt+'
Read more'; break; case 'newPost': var n = { subject: p.postAuthorName+' has created a new post: "'+p.postTitle+'"', text: p.postAuthorName+' has created a new post: "'+p.postTitle+'" '+getPostUrl(p.postId), html: ''+p.postAuthorName+' has created a new post: "'+p.postTitle+'".' }; break; case 'accountApproved': var n = { subject: 'Your account has been approved.', text: 'Welcome to '+getSetting('title')+'! Your account has just been approved.', html: 'Welcome to '+getSetting('title')+'!