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
|
2012-09-06 09:59:03 +09:00
|
|
|
, 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
|
|
|
|
2012-09-10 18:12:04 +09:00
|
|
|
var new_comment_id=Comments.insert(comment);
|
2012-09-08 12:11:26 +09:00
|
|
|
Posts.update(post_id, {$inc: {comments: 1}});
|
2012-09-20 08:09:45 +09:00
|
|
|
|
|
|
|
Meteor.call('upvoteComment', new_comment_id);
|
|
|
|
|
2012-09-10 18:12:04 +09:00
|
|
|
return new_comment_id;
|
2012-08-31 19:41:54 -04:00
|
|
|
}
|
|
|
|
});
|