Notifications = new Meteor.Collection('notifications'); 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.postHeadline+'"', text: p.commentAuthorName+' has replied to your comment on "'+p.postHeadline+'": '+getPostCommentUrl(p.postId, p.commentId), html: '
'+p.commentAuthorName+' has replied to your comment on "'+p.postHeadline+'"
' }; if(context == 'email') n.html += ''+p.commentExcerpt+'
Read more'; break; case 'newComment': var n = { subject: 'A new comment on your post "'+p.postHeadline+'"', text: 'You have a new comment by '+p.commentAuthorName+' on your post "'+p.postHeadline+'": '+getPostCommentUrl(p.postId, p.commentId), html: ''+p.commentAuthorName+' left a new comment on your post "'+p.postHeadline+'"
' }; if(context == 'email') n.html += ''+p.commentExcerpt+'
Read more'; break; case 'newPost': var n = { subject: p.postAuthorName+' has created a new post: "'+p.postHeadline+'"', text: p.postAuthorName+' has created a new post: "'+p.postHeadline+'" '+getPostUrl(p.postId), html: ''+p.postAuthorName+' has created a new post: "'+p.postHeadline+'".' }; 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')+'!