Created
March 25, 2015 10:54
-
-
Save adamgins/e9cd0504e1a12cd83073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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