diff --git a/src/controllers/groups.js b/src/controllers/groups.js index caa36809cc..06f87e82a5 100644 --- a/src/controllers/groups.js +++ b/src/controllers/groups.js @@ -292,14 +292,18 @@ api.clearFlagCount = function(req, res, next){ if(!message) return res.json(404, {err: "Message not found!"}); - if(user.contributor.admin) + if(user.contributor.admin){ message.flagCount = 0; + + group.markModified('chat'); + group.save(function(err,_saved){ + if(err) return next(err); + return res.send(204); + }); + }else{ + return res.json(401, {err: "Only an admin can clear the flag count!"}) + } - group.markModified('chat'); - group.save(function(err,_saved){ - if(err) return next(err); - return res.send(204); - }); } api.seenMessage = function(req,res,next){