This commit is contained in:
barisusakli
2014-07-21 15:03:01 -04:00
parent cb08d4b04f
commit 81018d1305
3 changed files with 39 additions and 62 deletions

View File

@@ -108,7 +108,7 @@ middleware.checkTopicIndex = function(req, res, next) {
var topicIndex = parseInt(req.params.topic_index, 10);
topicCount = parseInt(topicCount, 10) + 1;
var url = '';
if (topicIndex > topicCount) {
url = '/category/' + req.params.category_id + '/' + req.params.slug + '/' + topicCount;
return res.locals.isAPI ? res.json(302, url) : res.redirect(url);
@@ -190,45 +190,6 @@ middleware.checkAccountPermissions = function(req, res, next) {
});
};
/* Chat related middlewares */
middleware.chat = {};
middleware.chat.getMetadata = function(req, res, next) {
async.waterfall([
async.apply(user.getUidByUserslug, req.params.userslug),
function(toUid, next) {
user.getUserFields(toUid, ['uid', 'username'], next);
}
], function(err, chatData) {
if (!err) {
res.locals.chatData = chatData;
}
next();
});
};
middleware.chat.getContactList = function(req, res, next) {
user.getFollowing(req.user.uid, function(err, contacts) {
res.locals.contacts = contacts;
next();
});
};
middleware.chat.getMessages = function(req, res, next) {
if (res.locals.chatData) {
messaging.getMessages(req.user.uid, res.locals.chatData.uid, false, function(err, messages) {
res.locals.messages = messages;
next();
});
} else {
res.locals.messages = [];
next();
}
};
/* End Chat Middlewares */
middleware.buildHeader = function(req, res, next) {
res.locals.renderHeader = true;
async.parallel({