add GET /api/v2/groups/{gid}/chat route (query)

This commit is contained in:
Tyler Renelle
2014-01-14 09:21:51 -07:00
parent 23d4cba3d3
commit 3701003baf
2 changed files with 17 additions and 3 deletions
+7 -1
View File
@@ -195,7 +195,9 @@ api.update = function(req, res, next) {
}
api.attachGroup = function(req, res, next) {
Group.findById(req.params.gid, function(err, group){
var gid = req.params.gid;
var q = (gid == 'party') ? Group.findOne({type: 'party', members: {'$in': [res.locals.user._id]}}) : Group.findById(gid);
q.exec(function(err, group){
if(err) return res.json(500, {err:err});
if(!group) return res.json(404, {err: "Group not found"});
res.locals.group = group;
@@ -203,6 +205,10 @@ api.attachGroup = function(req, res, next) {
})
}
api.getChat = function(req, res, next) {
return res.json(res.locals.group.chat);
}
/**
* TODO make this it's own ngResource so we don't have to send down group data with each chat post
*/