diff --git a/client/views/comments/comment_item.js b/client/views/comments/comment_item.js index 62ddbcb4f..3b18a9953 100644 --- a/client/views/comments/comment_item.js +++ b/client/views/comments/comment_item.js @@ -137,7 +137,7 @@ Template.comment_item.helpers({ return true; }, ago: function(){ - return moment(this.submitted).fromNow(); + return moment(this.createdAt).fromNow(); }, upvoted: function(){ return Meteor.user() && _.include(this.upvoters, Meteor.user()._id); diff --git a/client/views/comments/comment_list.js b/client/views/comments/comment_list.js index 896515f68..3fc522c28 100644 --- a/client/views/comments/comment_list.js +++ b/client/views/comments/comment_list.js @@ -5,12 +5,12 @@ Template.comment_list.created = function(){ Template.comment_list.helpers({ has_comments: function(){ var post = this; - var comments = Comments.find({post: post._id, parent: null}, {sort: {score: -1, submitted: -1}}); + var comments = Comments.find({postId: post._id, parent: null}, {sort: {score: -1, submitted: -1}}); return comments.count() > 0; }, child_comments: function(){ var post = this; - var comments = Comments.find({post: post._id, parent: null}, {sort: {score: -1, submitted: -1}}); + var comments = Comments.find({postId: post._id, parent: null}, {sort: {score: -1, submitted: -1}}); return comments; } }); diff --git a/collections/comments.js b/collections/comments.js index d106b28f5..eb9e44418 100644 --- a/collections/comments.js +++ b/collections/comments.js @@ -2,7 +2,8 @@ Comments = new Meteor.Collection("comments", { schema: new SimpleSchema({ _id: { type: String, - regEx: SimpleSchema.RegEx.Id + regEx: SimpleSchema.RegEx.Id, + optional: true }, createdAt: { type: Date, @@ -13,10 +14,12 @@ Comments = new Meteor.Collection("comments", { }, baseScore: { type: Number, + decimal: true, optional: true }, score: { type: Number, + decimal: true, optional: true }, upvotes: { @@ -101,11 +104,15 @@ Meteor.methods({ throw new Meteor.Error(704,i18n.t('Your comment is empty.')); var comment = { - post: postId, - body: cleanText, - userId: user._id, - submitted: new Date().getTime(), - author: getDisplayName(user) + postId: postId, + body: cleanText, + userId: user._id, + createdAt: new Date(), + upvotes: 0, + downvotes: 0, + baseScore: 0, + score: 0, + author: getDisplayName(user) }; if(parentCommentId) diff --git a/server/publications.js b/server/publications.js index 12ee70ccb..143f5d221 100644 --- a/server/publications.js +++ b/server/publications.js @@ -43,7 +43,7 @@ Meteor.publish('postUsers', function(postId) { users = []; if(post) { - var comments = Comments.find({post: post._id}).fetch(); + var comments = Comments.find({postId: post._id}).fetch(); // get IDs from all commenters on the post, plus post author's ID users = _.pluck(comments, "userId"); users.push(post.userId); @@ -146,7 +146,7 @@ Meteor.publish('postsList', function(terms) { Meteor.publish('postComments', function(postId) { if(canViewById(this.userId)){ - return Comments.find({post: postId}); + return Comments.find({postId: postId}); } return []; });