mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-08 15:05:46 +01:00
filter:teasers.get provided with uid
This commit is contained in:
@@ -86,7 +86,7 @@ module.exports = function (Categories) {
|
||||
privileges.topics.filterTids('read', tids, uid, next);
|
||||
},
|
||||
function (tids, next) {
|
||||
getTopics(tids, next);
|
||||
getTopics(tids, uid, next);
|
||||
},
|
||||
function (topics, next) {
|
||||
assignTopicsToCategories(categoryData, topics);
|
||||
@@ -98,7 +98,7 @@ module.exports = function (Categories) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
function getTopics(tids, callback) {
|
||||
function getTopics(tids, uid, callback) {
|
||||
var topicData;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
@@ -119,7 +119,7 @@ module.exports = function (Categories) {
|
||||
|
||||
async.parallel({
|
||||
categoryData: async.apply(Categories.getCategoriesFields, cids, ['cid', 'parentCid']),
|
||||
teasers: async.apply(topics.getTeasers, _topicData),
|
||||
teasers: async.apply(topics.getTeasers, _topicData, uid),
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
|
||||
@@ -126,7 +126,7 @@ var social = require('./social');
|
||||
Topics.getUserBookmarks(tids, uid, next);
|
||||
},
|
||||
teasers: function (next) {
|
||||
Topics.getTeasers(topics, next);
|
||||
Topics.getTeasers(topics, uid, next);
|
||||
},
|
||||
tags: function (next) {
|
||||
Topics.getTopicsTagsObjects(tids, next);
|
||||
|
||||
@@ -12,7 +12,11 @@ var plugins = require('../plugins');
|
||||
var utils = require('../../public/src/utils');
|
||||
|
||||
module.exports = function (Topics) {
|
||||
Topics.getTeasers = function (topics, callback) {
|
||||
Topics.getTeasers = function (topics, uid, callback) {
|
||||
if (typeof uid === 'function') {
|
||||
callback = uid;
|
||||
uid = 0;
|
||||
}
|
||||
if (!Array.isArray(topics) || !topics.length) {
|
||||
return callback(null, []);
|
||||
}
|
||||
@@ -94,7 +98,7 @@ module.exports = function (Topics) {
|
||||
return tidToPost[topic.tid];
|
||||
});
|
||||
|
||||
plugins.fireHook('filter:teasers.get', { teasers: teasers }, next);
|
||||
plugins.fireHook('filter:teasers.get', { teasers: teasers, uid: uid }, next);
|
||||
},
|
||||
function (data, next) {
|
||||
next(null, data.teasers);
|
||||
@@ -102,7 +106,11 @@ module.exports = function (Topics) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
Topics.getTeasersByTids = function (tids, callback) {
|
||||
Topics.getTeasersByTids = function (tids, uid, callback) {
|
||||
if (typeof uid === 'function') {
|
||||
callback = uid;
|
||||
uid = 0;
|
||||
}
|
||||
if (!Array.isArray(tids) || !tids.length) {
|
||||
return callback(null, []);
|
||||
}
|
||||
@@ -111,13 +119,17 @@ module.exports = function (Topics) {
|
||||
Topics.getTopicsFields(tids, ['tid', 'postcount', 'teaserPid'], next);
|
||||
},
|
||||
function (topics, next) {
|
||||
Topics.getTeasers(topics, next);
|
||||
Topics.getTeasers(topics, uid, next);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
Topics.getTeaser = function (tid, callback) {
|
||||
Topics.getTeasersByTids([tid], function (err, teasers) {
|
||||
Topics.getTeaser = function (tid, uid, callback) {
|
||||
if (typeof uid === 'function') {
|
||||
callback = uid;
|
||||
uid = 0;
|
||||
}
|
||||
Topics.getTeasersByTids([tid], uid, function (err, teasers) {
|
||||
callback(err, Array.isArray(teasers) && teasers.length ? teasers[0] : null);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user