Loading comments/app.js +14 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,20 @@ app.post('/auth/:sdk/:version/comments/:commentId/undo_delete', Auth.isLoggedIn, }); }); // Tags a comment app.post('/auth/:sdk/:version/comments/:commentId/add_tag', Auth.isLoggedIn, Auth.isModerator, function(req, res) { new Request(req).addTag(req.params.commentId, req.body.tagname, function() { res.send({ success: true }); }); }); // Removes tag from a comment app.post('/auth/:sdk/:version/comments/:commentId/remove_tag', Auth.isLoggedIn, Auth.isModerator, function(req, res) { new Request(req).removeTag(req.params.commentId, req.body.tagname, function() { res.send({ success: true }); }); }); // Marks a comment 'read' app.post('/auth/:sdk/:version/comments/:commentId/read', Auth.isLoggedIn, function(req, res) { new Request(req).markRead(req.params.commentId, function() { Loading comments/lib/auth.js +12 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,18 @@ var Auth = { }); }, /** * Throws error when logged in user isn't moderator. */ isModerator: function(req, res, next) { if (new Request(req).isModerator()) { next(); } else { res.json({ success: false, reason: 'Forbidden' }, 403); } }, /** * Throws error when logged in user can't vote on the comment in * question. Loading comments/lib/request.js +21 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,27 @@ Request.prototype = { }); }, /** * Adds tag to comment. */ addTag: function(comment_id, tagname, callback) { this.db.comments().addTag({ user_id: this.getUserId(), comment_id: comment_id, tagname: tagname }, callback); }, /** * Removes tag from comment. */ removeTag: function(comment_id, tagname, callback) { this.db.comments().removeTag({ comment_id: comment_id, tagname: tagname }, callback); }, /** * Marks comment as read. */ Loading Loading
comments/app.js +14 −0 Original line number Diff line number Diff line Loading @@ -206,6 +206,20 @@ app.post('/auth/:sdk/:version/comments/:commentId/undo_delete', Auth.isLoggedIn, }); }); // Tags a comment app.post('/auth/:sdk/:version/comments/:commentId/add_tag', Auth.isLoggedIn, Auth.isModerator, function(req, res) { new Request(req).addTag(req.params.commentId, req.body.tagname, function() { res.send({ success: true }); }); }); // Removes tag from a comment app.post('/auth/:sdk/:version/comments/:commentId/remove_tag', Auth.isLoggedIn, Auth.isModerator, function(req, res) { new Request(req).removeTag(req.params.commentId, req.body.tagname, function() { res.send({ success: true }); }); }); // Marks a comment 'read' app.post('/auth/:sdk/:version/comments/:commentId/read', Auth.isLoggedIn, function(req, res) { new Request(req).markRead(req.params.commentId, function() { Loading
comments/lib/auth.js +12 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,18 @@ var Auth = { }); }, /** * Throws error when logged in user isn't moderator. */ isModerator: function(req, res, next) { if (new Request(req).isModerator()) { next(); } else { res.json({ success: false, reason: 'Forbidden' }, 403); } }, /** * Throws error when logged in user can't vote on the comment in * question. Loading
comments/lib/request.js +21 −0 Original line number Diff line number Diff line Loading @@ -198,6 +198,27 @@ Request.prototype = { }); }, /** * Adds tag to comment. */ addTag: function(comment_id, tagname, callback) { this.db.comments().addTag({ user_id: this.getUserId(), comment_id: comment_id, tagname: tagname }, callback); }, /** * Removes tag from comment. */ removeTag: function(comment_id, tagname, callback) { this.db.comments().removeTag({ comment_id: comment_id, tagname: tagname }, callback); }, /** * Marks comment as read. */ Loading