Vulcan/server/comment.js

22 lines
511 B
JavaScript
Raw Normal View History

2012-08-31 19:41:54 -04:00
Meteor.methods({
2012-09-08 12:11:26 +09:00
comment: function(post_id, parentComment_id, text){
2012-08-31 19:41:54 -04:00
var user = Meteor.users.findOne(this.userId());
var comment = {
2012-09-08 12:11:26 +09:00
post: post_id
2012-08-31 19:41:54 -04:00
, body: text
, user_id: user._id
2012-08-31 19:41:54 -04:00
, submitted: new Date().getTime()
};
2012-09-08 12:11:26 +09:00
if(parentComment_id)
comment.parent = parentComment_id;
2012-08-31 19:41:54 -04:00
var new_comment_id=Comments.insert(comment);
2012-09-08 12:11:26 +09:00
Posts.update(post_id, {$inc: {comments: 1}});
Meteor.call('upvoteComment', new_comment_id);
return new_comment_id;
2012-08-31 19:41:54 -04:00
}
});