mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 06:55:46 +01:00
closes #5779
This commit is contained in:
@@ -19,7 +19,7 @@ module.exports = function (Categories) {
|
||||
}, { alwaysStartAt: 0 }, next);
|
||||
},
|
||||
function (next) {
|
||||
Categories.getPinnedTids('cid:' + cid + ':tids:pinned', 0, -1, next);
|
||||
db.getSortedSetRevRange('cid:' + cid + ':tids:pinned', 0, -1, next);
|
||||
},
|
||||
function (pinnedTids, next) {
|
||||
async.eachLimit(pinnedTids, 10, function (tid, next) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var _ = require('lodash');
|
||||
|
||||
var db = require('../database');
|
||||
var topics = require('../topics');
|
||||
@@ -41,7 +42,10 @@ module.exports = function (Categories) {
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Categories.getPinnedTids(data.cid, 0, -1, next);
|
||||
var dataForPinned = _.cloneDeep(data);
|
||||
dataForPinned.start = 0;
|
||||
dataForPinned.stop = -1;
|
||||
Categories.getPinnedTids(dataForPinned, next);
|
||||
},
|
||||
function (_pinnedTids, next) {
|
||||
var totalPinnedCount = _pinnedTids.length;
|
||||
@@ -148,8 +152,17 @@ module.exports = function (Categories) {
|
||||
db.getSortedSetRange(['cid:' + cid + ':tids:pinned', 'cid:' + cid + ':tids'], start, stop, callback);
|
||||
};
|
||||
|
||||
Categories.getPinnedTids = function (cid, start, stop, callback) {
|
||||
db.getSortedSetRevRange('cid:' + cid + ':tids:pinned', start, stop, callback);
|
||||
Categories.getPinnedTids = function (data, callback) {
|
||||
if (plugins.hasListeners('filter:categories.getPinnedTids')) {
|
||||
return plugins.fireHook('filter:categories.getPinnedTids', {
|
||||
pinnedTids: [],
|
||||
data: data,
|
||||
}, function (err, data) {
|
||||
callback(err, data && data.pinnedTids);
|
||||
});
|
||||
}
|
||||
|
||||
db.getSortedSetRevRange('cid:' + data.cid + ':tids:pinned', data.start, data.stop, callback);
|
||||
};
|
||||
|
||||
Categories.modifyTopicsByPrivilege = function (topics, privileges) {
|
||||
|
||||
@@ -154,16 +154,13 @@ module.exports = function (Topics) {
|
||||
var topicData;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Topics.exists(tid, next);
|
||||
},
|
||||
function (exists, next) {
|
||||
if (!exists) {
|
||||
return callback(new Error('[[error:no-topic]]'));
|
||||
}
|
||||
Topics.getTopicFields(tid, ['uid', 'tid', 'cid', 'lastposttime', 'postcount'], next);
|
||||
Topics.getTopicData(tid, next);
|
||||
},
|
||||
function (_topicData, next) {
|
||||
topicData = _topicData;
|
||||
if (!topicData) {
|
||||
return callback(new Error('[[error:no-topic]]'));
|
||||
}
|
||||
privileges.categories.isAdminOrMod(_topicData.cid, uid, next);
|
||||
},
|
||||
function (isAdminOrMod, next) {
|
||||
|
||||
Reference in New Issue
Block a user