Added fallback for is message does not contain flags key. Added error
for if message was already flagged by user
This commit is contained in:
@@ -264,6 +264,9 @@ api.flagChatMessage = function(req, res, next){
|
||||
if(!message) return res.json(404, {err: "Message not found!"});
|
||||
if(message.uuid == user._id) return res.json(401, {err: "Can't report your own message."});
|
||||
|
||||
if(!message.flags) message.flags = {};
|
||||
if(message.flags[user._id]) return res.json(401, {err: "You have already reported this message"});
|
||||
|
||||
message.flags[user._id] = true;
|
||||
group.markModified('chat');
|
||||
group.save(function(err,_saved){
|
||||
|
||||
Reference in New Issue
Block a user