mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-10 00:27:35 +01:00
Merge branch 'master' of https://github.com/NodeBB/NodeBB
This commit is contained in:
@@ -4,6 +4,7 @@ var accountsController = {
|
||||
profile: require('./accounts/profile'),
|
||||
edit: require('./accounts/edit'),
|
||||
info: require('./accounts/info'),
|
||||
categories: require('./accounts/categories'),
|
||||
settings: require('./accounts/settings'),
|
||||
groups: require('./accounts/groups'),
|
||||
follow: require('./accounts/follow'),
|
||||
|
||||
43
src/controllers/accounts/categories.js
Normal file
43
src/controllers/accounts/categories.js
Normal file
@@ -0,0 +1,43 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var user = require('../../user');
|
||||
var categories = require('../../categories');
|
||||
var accountHelpers = require('./helpers');
|
||||
|
||||
var categoriesController = module.exports;
|
||||
|
||||
categoriesController.get = function (req, res, callback) {
|
||||
var userData;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
accountHelpers.getUserDataByUserSlug(req.params.userslug, req.uid, next);
|
||||
},
|
||||
function (_userData, next) {
|
||||
userData = _userData;
|
||||
if (!userData) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
ignored: function (next) {
|
||||
user.getIgnoredCategories(userData.uid, next);
|
||||
},
|
||||
categories: function (next) {
|
||||
categories.buildForSelect(userData.uid, 'find', next);
|
||||
},
|
||||
}, next);
|
||||
},
|
||||
function (results) {
|
||||
results.categories.forEach(function (category) {
|
||||
if (category) {
|
||||
category.isIgnored = results.ignored.includes(String(category.cid));
|
||||
}
|
||||
});
|
||||
userData.categories = results.categories;
|
||||
userData.title = '[[pages:account/watched_categories, ' + userData.username + ']]';
|
||||
res.render('account/categories', userData);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
@@ -14,6 +14,7 @@ module.exports = function (app, middleware, controllers) {
|
||||
setupPageRoute(app, '/user/:userslug/following', middleware, middlewares, controllers.accounts.follow.getFollowing);
|
||||
setupPageRoute(app, '/user/:userslug/followers', middleware, middlewares, controllers.accounts.follow.getFollowers);
|
||||
|
||||
setupPageRoute(app, '/user/:userslug/categories', middleware, middlewares, controllers.accounts.categories.get);
|
||||
setupPageRoute(app, '/user/:userslug/posts', middleware, middlewares, controllers.accounts.posts.getPosts);
|
||||
setupPageRoute(app, '/user/:userslug/topics', middleware, middlewares, controllers.accounts.posts.getTopics);
|
||||
setupPageRoute(app, '/user/:userslug/best', middleware, middlewares, controllers.accounts.posts.getBestPosts);
|
||||
|
||||
@@ -174,7 +174,17 @@ SocketCategories.ignore = function (socket, cid, callback) {
|
||||
};
|
||||
|
||||
function ignoreOrWatch(fn, socket, cid, callback) {
|
||||
var targetUid = socket.uid;
|
||||
var cids = [parseInt(cid, 10)];
|
||||
if (typeof cid === 'object') {
|
||||
targetUid = cid.uid;
|
||||
cids = [parseInt(cid.cid, 10)];
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
user.isAdminOrGlobalModOrSelf(socket.uid, targetUid, next);
|
||||
},
|
||||
function (next) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, next);
|
||||
},
|
||||
@@ -187,10 +197,7 @@ function ignoreOrWatch(fn, socket, cid, callback) {
|
||||
c.parentCid = parseInt(c.parentCid, 10);
|
||||
});
|
||||
|
||||
var cids = [parseInt(cid, 10)];
|
||||
|
||||
// filter to subcategories of cid
|
||||
|
||||
var cat;
|
||||
do {
|
||||
cat = categoryData.find(function (c) {
|
||||
@@ -202,11 +209,14 @@ function ignoreOrWatch(fn, socket, cid, callback) {
|
||||
} while (cat);
|
||||
|
||||
async.each(cids, function (cid, next) {
|
||||
fn(socket.uid, cid, next);
|
||||
fn(targetUid, cid, next);
|
||||
}, next);
|
||||
},
|
||||
function (next) {
|
||||
topics.pushUnreadCount(socket.uid, next);
|
||||
topics.pushUnreadCount(targetUid, next);
|
||||
},
|
||||
function (next) {
|
||||
next(null, cids);
|
||||
},
|
||||
], callback);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user