mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-12 17:05:51 +01:00
fixed #2704
This commit is contained in:
@@ -27,26 +27,32 @@ groupsController.list = function(req, res, next) {
|
|||||||
groupsController.details = function(req, res, next) {
|
groupsController.details = function(req, res, next) {
|
||||||
var uid = req.user ? parseInt(req.user.uid, 10) : 0;
|
var uid = req.user ? parseInt(req.user.uid, 10) : 0;
|
||||||
|
|
||||||
async.parallel({
|
groups.existsBySlug(req.params.slug, function(err, exists) {
|
||||||
group: function(next) {
|
if (exists) {
|
||||||
groups.getByGroupslug(req.params.slug, {
|
async.parallel({
|
||||||
expand: true,
|
group: function(next) {
|
||||||
uid: uid
|
groups.getByGroupslug(req.params.slug, {
|
||||||
}, next);
|
expand: true,
|
||||||
},
|
uid: uid
|
||||||
posts: function(next) {
|
}, next);
|
||||||
groups.getLatestMemberPosts(req.params.slug, 10, uid, next);
|
},
|
||||||
}
|
posts: function(next) {
|
||||||
}, function(err, results) {
|
groups.getLatestMemberPosts(req.params.slug, 10, uid, next);
|
||||||
if (err) {
|
}
|
||||||
return next(err);
|
}, function(err, results) {
|
||||||
}
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
if (!results.group) {
|
if (!results.group) {
|
||||||
return helpers.notFound(req, res);
|
return helpers.notFound(req, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
res.render('groups/details', results);
|
res.render('groups/details', results);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return res.locals.isAPI ? res.status(302).json('/groups') : res.redirect('/groups');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -422,6 +422,10 @@ var async = require('async'),
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Groups.existsBySlug = function(slug, callback) {
|
||||||
|
db.isObjectField('groupslug:groupname', slug, callback);
|
||||||
|
};
|
||||||
|
|
||||||
Groups.create = function(data, callback) {
|
Groups.create = function(data, callback) {
|
||||||
if (data.name.length === 0) {
|
if (data.name.length === 0) {
|
||||||
return callback(new Error('[[error:group-name-too-short]]'));
|
return callback(new Error('[[error:group-name-too-short]]'));
|
||||||
|
|||||||
Reference in New Issue
Block a user