Node.js based forum software built for the modern web
completed basic integration for #6463
Julian Lam4f6cc204579c
diff --git a/src/controllers/unread.js b/src/controllers/unread.jsindex b4b8e23f38..d7de3d8e91 100644--- a/src/controllers/unread.js+++ b/src/controllers/unread.js@@ -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));diff --git a/src/messaging.js b/src/messaging.jsindex 6b0462eb0e..7267e16a9e 100644--- a/src/messaging.js+++ b/src/messaging.js@@ -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) {diff --git a/src/topics/recent.js b/src/topics/recent.jsindex 2e77262d44..30da085deb 100644--- a/src/topics/recent.js+++ b/src/topics/recent.js@@ -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) {diff --git a/src/user/blocks.js b/src/user/blocks.jsindex bd4879136f..093ea518f3 100644--- a/src/user/blocks.js+++ b/src/user/blocks.js@@ -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 optionalif (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 uidsif (!Array.isArray(set) || !(set[0].hasOwnProperty(property) || typeof set[0] === 'number' || typeof set[0] === 'string')) {return callback(null, set);}