Loading opt/comments-server-side/app.js +18 −2 Original line number Diff line number Diff line Loading @@ -256,11 +256,27 @@ app.post('/auth/:sdk/:version/comments', util.requireLoggedInUser, function(req, url: req.body.url }); comment.save(function(err, response) { res.json({ success: true, id: response._id, action: req.body.action }); var afterSave = function() { res.json({ success: true, id: comment._id, action: req.body.action }); util.sendEmailUpdates(comment); }; comment.save(function(err) { if (util.isModerator(req.session.user)) { // When moderator posts comment, mark it automatically as read. var meta = new Meta({ userId: req.session.user.userid, commentId: comment._id, metaType: 'read' }); meta.save(afterSave); } else { afterSave(); } }); }); /** Loading opt/comments-server-side/util.js +8 −2 Original line number Diff line number Diff line Loading @@ -171,15 +171,21 @@ exports.findCommentMeta = function(req, res, next) { } }; // True if the user is moderator /** * True if the user is moderator */ function isModerator(user) { return _.include(user.membergroupids, 7); } exports.isModerator = isModerator; // True if the user is author of the comment /** * True if the user is author of the comment */ function isAuthor(user, comment) { return user.username === comment.author; } exports.isAuthor = isAuthor; /** * Ensures that user is allowed to modify/delete the comment, Loading Loading
opt/comments-server-side/app.js +18 −2 Original line number Diff line number Diff line Loading @@ -256,11 +256,27 @@ app.post('/auth/:sdk/:version/comments', util.requireLoggedInUser, function(req, url: req.body.url }); comment.save(function(err, response) { res.json({ success: true, id: response._id, action: req.body.action }); var afterSave = function() { res.json({ success: true, id: comment._id, action: req.body.action }); util.sendEmailUpdates(comment); }; comment.save(function(err) { if (util.isModerator(req.session.user)) { // When moderator posts comment, mark it automatically as read. var meta = new Meta({ userId: req.session.user.userid, commentId: comment._id, metaType: 'read' }); meta.save(afterSave); } else { afterSave(); } }); }); /** Loading
opt/comments-server-side/util.js +8 −2 Original line number Diff line number Diff line Loading @@ -171,15 +171,21 @@ exports.findCommentMeta = function(req, res, next) { } }; // True if the user is moderator /** * True if the user is moderator */ function isModerator(user) { return _.include(user.membergroupids, 7); } exports.isModerator = isModerator; // True if the user is author of the comment /** * True if the user is author of the comment */ function isAuthor(user, comment) { return user.username === comment.author; } exports.isAuthor = isAuthor; /** * Ensures that user is allowed to modify/delete the comment, Loading