disallow fetching of chat messages

This commit is contained in:
Alice Harris 2015-01-13 06:10:46 +10:00
parent c9f5113daa
commit 0bd22e7c77

View file

@ -211,8 +211,23 @@ api.attachGroup = function(req, res, next) {
}
api.getChat = function(req, res, next) {
return res.json(res.locals.group.chat);
}
// TODO: This code is duplicated from api.get - pull it out into a function to remove duplication.
var user = res.locals.user;
var gid = req.params.gid;
var q = (gid == 'party')
? Group.findOne({type: 'party', members: {$in:[user._id]}})
: Group.findOne({$or:[
{_id:gid, privacy:'public'},
{_id:gid, privacy:'private', members: {$in:[user._id]}}
]});
populateQuery(gid, q);
q.exec(function(err, group){
if (err) return next(err);
if (!group && gid!=='party') return res.json(404,{err: "Group not found or you don't have access."});
res.json(res.locals.group.chat);
gid = null;
});
};
/**
* TODO make this it's own ngResource so we don't have to send down group data with each chat post