From a9f80bd860e34f687d69c3dddb730d0f52b6866e Mon Sep 17 00:00:00 2001 From: Matteo Pagliazzi Date: Tue, 22 Apr 2014 14:19:56 +0200 Subject: [PATCH] fix(notifications): check for group id to be sent with seenMessage --- src/controllers/groups.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/controllers/groups.js b/src/controllers/groups.js index 249b4bd2ca..29a4954eec 100644 --- a/src/controllers/groups.js +++ b/src/controllers/groups.js @@ -254,9 +254,12 @@ api.deleteChatMessage = function(req, res, next){ api.seenMessage = function(req,res,next){ // Skip the auth step, we want this to be fast. If !found with uuid/token, then it just doesn't save - var update = {$set:{}}; - update['$set']['newMessages.'+req.params.gid+'.value'] = false; - User.update({_id:req.headers['x-api-user'], apiToken:req.headers['x-api-key']},update).exec(); + // Check for req.params.gid to exist + if(req.params.gid){ + var update = {$set:{}}; + update['$set']['newMessages.'+req.params.gid+'.value'] = false; + User.update({_id:req.headers['x-api-user'], apiToken:req.headers['x-api-key']},update).exec(); + } res.send(200); }