Merge branch 'master' into preserve-comment-view-state

This commit is contained in:
Wyatt Johnson
2017-01-13 15:20:49 -07:00
committed by GitHub
6 changed files with 84 additions and 48 deletions
+10 -2
View File
@@ -266,8 +266,16 @@ CommentSchema.statics.all = () => Comment.find();
* probably to be paginated at some point in the future
* @return {Promise} array resolves to an array of comments by that user
*/
CommentSchema.statics.findByUserId = function (author_id) {
return Comment.find({author_id});
CommentSchema.statics.findByUserId = function (author_id, admin = false) {
// do not return un-published comments for non-admins
let query = {author_id};
if (!admin) {
query.$nor = [{status: 'premod'}, {status: 'rejected'}];
}
return Comment.find(query);
};
// Comment model.