Skip to content

Instantly share code, notes, and snippets.

@adamgins
Created March 25, 2015 10:54
Show Gist options
  • Save adamgins/e9cd0504e1a12cd83073 to your computer and use it in GitHub Desktop.
Save adamgins/e9cd0504e1a12cd83073 to your computer and use it in GitHub Desktop.
addComment: function(commentStuff) {
var user = Meteor.user();
var submittedDate;
if (Meteor.isClient){
submittedDate = TimeSync.serverTime();
} else {
submittedDate = new Date().getTime();
}
comment = _.extend(_.pick(commentStuff, 'message','parentID'), {
userID: user._id,
author: gGetUserNameByID(user._id),
submitted: submittedDate,
status:status,
_id: new Meteor.Collection.ObjectID()._str
});
comment._id = Comments.insert(comment);
// now create a notification, informing the user that there's been a comment
createCommentNotification(comment,parentResourceID, truncatedText ); // this does a push notification
//the folllowing updates the count on the parent topic
Meteor.call("updateResourceCommentCount",commentStuff.parentID, function(error){
if (error){
throwError("Error updating comment count");
}
});
Meteor.call("updateUpdatedDate", parentResourceID);
return;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment