12345678910111213141516171819202122 |
- Notifications = new Mongo.Collection('notifications');
- Notifications.allow({
- update: function (userId, doc, fieldNames) {
- // Only allow post author to update, and only the "read" field.
- return ownsDocument(userId, doc) &&
- fieldNames.length === 1 && fieldNames[0] === 'read';
- }
- });
- createCommentNotification = function (comment) {
- var post = Posts.findOne(comment.postId);
- if (comment.userId !== post.userId) {
- Notifications.insert({
- userId: post.userId,
- postId: post._id,
- commentId: comment._id,
- commenterName: comment.author,
- read: false
- });
- }
- };
|