Skip to content

Commit

Permalink
Add likes
Browse files Browse the repository at this point in the history
  • Loading branch information
MBenedicte committed Aug 5, 2019
1 parent 2b7043b commit f18da89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/controllers/CommentLikeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class CommentLikeController {
await updateCommentLikes(req);
return res.status(status.CREATED).send({
message: 'You liked the comment',
like: likeComment
createLike: likeComment
});
}

Expand All @@ -31,9 +31,10 @@ export default class CommentLikeController {
* @returns {object} the return after liking a particular article
*/
static async getAll(req, res) {
const { articleSlug } = req.params;
const findAllLikes = await comment.getAllLikes({ articleSlug });
const { articleSlug, commentId } = req.params;
const findAllLikes = await comment.getAllLikes({ articleSlug, commentId });
return res.status(status.OK).json({
commentId,
likes: findAllLikes.length,
whoLiked: { userId: findAllLikes.map(value => value.userId) }
});
Expand Down
3 changes: 2 additions & 1 deletion src/middlewares/checkCommentLike.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ const checkArticleLike = async (req, res, next) => {
await comment.deleteLike(like);
await updateCommentLikes(req);
res.status(statusCode.OK).json({
errors: { message }
message,
createLike: findLike
});
};
export default checkArticleLike;

0 comments on commit f18da89

Please sign in to comment.