completed basic integration for #6463

v1.18.x
Julian Lam 7 years ago
parent 322d8236d2
commit 4f6cc20457

@ -54,6 +54,12 @@ unreadController.get = function (req, res, next) {
cutoff: cutoff,
}, next);
},
function (data, next) {
user.blocks.filter(req.uid, data.topics, function (err, filtered) {
data.topics = filtered;
next(err, data);
});
},
function (data) {
data.title = meta.config.homePageTitle || '[[pages:home]]';
data.pageCount = Math.max(1, Math.ceil(data.topicCount / settings.topicsPerPage));

@ -219,6 +219,15 @@ Messaging.getTeaser = function (uid, roomId, callback) {
}
Messaging.getMessageFields(mids[0], ['fromuid', 'content', 'timestamp'], next);
},
function (teaser, next) {
user.blocks.is(teaser.fromuid, uid, function (err, blocked) {
if (err || blocked) {
return callback(err);
}
next(null, teaser);
});
},
function (_teaser, next) {
teaser = _teaser;
if (!teaser) {

@ -77,10 +77,20 @@ module.exports = function (Topics) {
user.getIgnoredCategories(uid, next);
},
topicData: function (next) {
Topics.getTopicsFields(tids, ['tid', 'cid'], next);
Topics.getTopicsFields(tids, ['uid', 'tid', 'cid'], next);
},
}, next);
},
function (results, next) {
user.blocks.filter(uid, results.topicData, function (err, filtered) {
if (err) {
return next(err);
}
results.topicData = filtered;
next(null, results);
});
},
function (results, next) {
cid = cid && cid.map(String);
tids = results.topicData.filter(function (topic) {

@ -29,9 +29,6 @@ module.exports = function (User) {
return callback(err);
}
// for debugging
// blocked = [2];
blocked = blocked.map(uid => parseInt(uid, 10)).filter(Boolean);
User.blocks._cache.set(uid, blocked);
callback(null, blocked);
@ -61,6 +58,7 @@ module.exports = function (User) {
};
User.blocks.filter = function (uid, property, set, callback) {
// Given whatever is passed in, iterates through it, and removes entries made by blocked uids
// property is optional
if (Array.isArray(property) && typeof set === 'function' && !callback) {
callback = set;
@ -68,7 +66,6 @@ module.exports = function (User) {
property = 'uid';
}
// Given whatever is passed in, iterates through it, and removes entries made by blocked uids
if (!Array.isArray(set) || !(set[0].hasOwnProperty(property) || typeof set[0] === 'number' || typeof set[0] === 'string')) {
return callback(null, set);
}

Loading…
Cancel
Save