From 84dcf3b3b63aaaeafe976d31701e93547d7f68f5 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Thu, 16 Feb 2017 15:47:24 -0700 Subject: [PATCH] Added some comments --- graph/loaders/comments.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/graph/loaders/comments.js b/graph/loaders/comments.js index a6b808ef2..ad78a1e92 100644 --- a/graph/loaders/comments.js +++ b/graph/loaders/comments.js @@ -133,6 +133,7 @@ const getCommentsByQuery = ({user}, {ids, statuses, asset_id, parent_id, author_ }); } + // Only let an admin request any user or the current user request themself. if (user && (user.hasRoles('ADMIN') || user.id === author_id) && author_id != null) { comments = comments.where({author_id}); } @@ -168,7 +169,13 @@ const getCommentsByQuery = ({user}, {ids, statuses, asset_id, parent_id, author_ .limit(limit); }; -const genRecentReplies = (_, ids) => { +/** + * Gets the recent replies. + * @param {Object} context graph context + * @param {Array} ids ids of parent ids + * @return {Promise} resolves to recent replies + */ +const genRecentReplies = (context, ids) => { return CommentModel.aggregate([ // get all the replies for the comments in question @@ -212,6 +219,12 @@ const genRecentReplies = (_, ids) => { .then(util.arrayJoinBy(ids, 'parent_id')); }; +/** + * Gets the recent comments. + * @param {Object} context graph context + * @param {Array} ids ids of asset ids + * @return {Promise} resolves to recent comments from assets + */ const genRecentComments = (_, ids) => { return CommentModel.aggregate([