mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
Fix space-before-function-paren linter rule
This commit is contained in:
@@ -12,20 +12,20 @@ var privileges = require('../privileges');
|
||||
var meta = require('../meta');
|
||||
var utils = require('../../public/src/utils');
|
||||
|
||||
module.exports = function(Topics) {
|
||||
module.exports = function (Topics) {
|
||||
|
||||
Topics.getTotalUnread = function(uid, filter, callback) {
|
||||
Topics.getTotalUnread = function (uid, filter, callback) {
|
||||
if (!callback) {
|
||||
callback = filter;
|
||||
filter = '';
|
||||
}
|
||||
Topics.getUnreadTids(0, uid, filter, function(err, tids) {
|
||||
Topics.getUnreadTids(0, uid, filter, function (err, tids) {
|
||||
callback(err, Array.isArray(tids) ? tids.length : 0);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Topics.getUnreadTopics = function(cid, uid, start, stop, filter, callback) {
|
||||
Topics.getUnreadTopics = function (cid, uid, start, stop, filter, callback) {
|
||||
|
||||
var unreadTopics = {
|
||||
showSelect: true,
|
||||
@@ -34,10 +34,10 @@ module.exports = function(Topics) {
|
||||
};
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
Topics.getUnreadTids(cid, uid, filter, next);
|
||||
},
|
||||
function(tids, next) {
|
||||
function (tids, next) {
|
||||
unreadTopics.topicCount = tids.length;
|
||||
|
||||
if (!tids.length) {
|
||||
@@ -52,7 +52,7 @@ module.exports = function(Topics) {
|
||||
|
||||
Topics.getTopicsByTids(tids, uid, next);
|
||||
},
|
||||
function(topicData, next) {
|
||||
function (topicData, next) {
|
||||
if (!Array.isArray(topicData) || !topicData.length) {
|
||||
return next(null, unreadTopics);
|
||||
}
|
||||
@@ -64,11 +64,11 @@ module.exports = function(Topics) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
Topics.unreadCutoff = function() {
|
||||
Topics.unreadCutoff = function () {
|
||||
return Date.now() - (parseInt(meta.config.unreadCutoff, 10) || 2) * 86400000;
|
||||
};
|
||||
|
||||
Topics.getUnreadTids = function(cid, uid, filter, callback) {
|
||||
Topics.getUnreadTids = function (cid, uid, filter, callback) {
|
||||
uid = parseInt(uid, 10);
|
||||
if (uid === 0) {
|
||||
return callback(null, []);
|
||||
@@ -81,22 +81,22 @@ module.exports = function(Topics) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
async.parallel({
|
||||
ignoredCids: function(next) {
|
||||
ignoredCids: function (next) {
|
||||
if (filter === 'watched') {
|
||||
return next(null, []);
|
||||
}
|
||||
user.getIgnoredCategories(uid, next);
|
||||
},
|
||||
ignoredTids: function(next) {
|
||||
ignoredTids: function (next) {
|
||||
user.getIgnoredTids(uid, 0, -1, next);
|
||||
},
|
||||
recentTids: function(next) {
|
||||
recentTids: function (next) {
|
||||
db.getSortedSetRevRangeByScoreWithScores('topics:recent', 0, -1, '+inf', cutoff, next);
|
||||
},
|
||||
userScores: function(next) {
|
||||
userScores: function (next) {
|
||||
db.getSortedSetRevRangeByScoreWithScores('uid:' + uid + ':tids_read', 0, -1, '+inf', cutoff, next);
|
||||
},
|
||||
tids_unread: function(next) {
|
||||
tids_unread: function (next) {
|
||||
db.getSortedSetRevRangeWithScores('uid:' + uid + ':tids_unread', 0, -1, next);
|
||||
}
|
||||
}, next);
|
||||
@@ -109,16 +109,16 @@ module.exports = function(Topics) {
|
||||
ignoredCids = results.ignoredCids;
|
||||
|
||||
var userRead = {};
|
||||
results.userScores.forEach(function(userItem) {
|
||||
results.userScores.forEach(function (userItem) {
|
||||
userRead[userItem.value] = userItem.score;
|
||||
});
|
||||
|
||||
results.recentTids = results.recentTids.concat(results.tids_unread);
|
||||
results.recentTids.sort(function(a, b) {
|
||||
results.recentTids.sort(function (a, b) {
|
||||
return b.score - a.score;
|
||||
});
|
||||
|
||||
var tids = results.recentTids.filter(function(recentTopic) {
|
||||
var tids = results.recentTids.filter(function (recentTopic) {
|
||||
if (results.ignoredTids.indexOf(recentTopic.value.toString()) !== -1) {
|
||||
return false;
|
||||
}
|
||||
@@ -128,9 +128,9 @@ module.exports = function(Topics) {
|
||||
default:
|
||||
return !userRead[recentTopic.value] || recentTopic.score > userRead[recentTopic.value];
|
||||
}
|
||||
}).map(function(topic) {
|
||||
}).map(function (topic) {
|
||||
return topic.value;
|
||||
}).filter(function(tid, index, array) {
|
||||
}).filter(function (tid, index, array) {
|
||||
return array.indexOf(tid) === index;
|
||||
});
|
||||
|
||||
@@ -150,11 +150,11 @@ module.exports = function(Topics) {
|
||||
};
|
||||
|
||||
function filterWatchedTids(uid, tids, callback) {
|
||||
db.sortedSetScores('uid:' + uid + ':followed_tids', tids, function(err, scores) {
|
||||
db.sortedSetScores('uid:' + uid + ':followed_tids', tids, function (err, scores) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
tids = tids.filter(function(tid, index) {
|
||||
tids = tids.filter(function (tid, index) {
|
||||
return tid && !!scores[index];
|
||||
});
|
||||
callback(null, tids);
|
||||
@@ -167,15 +167,15 @@ module.exports = function(Topics) {
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
privileges.topics.filterTids('read', tids, uid, next);
|
||||
},
|
||||
function(tids, next) {
|
||||
function (tids, next) {
|
||||
async.parallel({
|
||||
topics: function(next) {
|
||||
topics: function (next) {
|
||||
Topics.getTopicsFields(tids, ['tid', 'cid'], next);
|
||||
},
|
||||
isTopicsFollowed: function(next) {
|
||||
isTopicsFollowed: function (next) {
|
||||
if (filter === 'watched' || filter === 'new') {
|
||||
return next(null, []);
|
||||
}
|
||||
@@ -183,13 +183,13 @@ module.exports = function(Topics) {
|
||||
}
|
||||
}, next);
|
||||
},
|
||||
function(results, next) {
|
||||
function (results, next) {
|
||||
var topics = results.topics;
|
||||
tids = topics.filter(function(topic, index) {
|
||||
tids = topics.filter(function (topic, index) {
|
||||
return topic && topic.cid &&
|
||||
(!!results.isTopicsFollowed[index] || ignoredCids.indexOf(topic.cid.toString()) === -1) &&
|
||||
(!cid || parseInt(cid, 10) === parseInt(topic.cid, 10));
|
||||
}).map(function(topic) {
|
||||
}).map(function (topic) {
|
||||
return topic.tid;
|
||||
});
|
||||
next(null, tids);
|
||||
@@ -197,13 +197,13 @@ module.exports = function(Topics) {
|
||||
], callback);
|
||||
}
|
||||
|
||||
Topics.pushUnreadCount = function(uid, callback) {
|
||||
callback = callback || function() {};
|
||||
Topics.pushUnreadCount = function (uid, callback) {
|
||||
callback = callback || function () {};
|
||||
|
||||
if (!uid || parseInt(uid, 10) === 0) {
|
||||
return callback();
|
||||
}
|
||||
Topics.getTotalUnread(uid, function(err, count) {
|
||||
Topics.getTotalUnread(uid, function (err, count) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -213,17 +213,17 @@ module.exports = function(Topics) {
|
||||
});
|
||||
};
|
||||
|
||||
Topics.markAsUnreadForAll = function(tid, callback) {
|
||||
Topics.markAsUnreadForAll = function (tid, callback) {
|
||||
Topics.markCategoryUnreadForAll(tid, callback);
|
||||
};
|
||||
|
||||
Topics.markAsRead = function(tids, uid, callback) {
|
||||
callback = callback || function() {};
|
||||
Topics.markAsRead = function (tids, uid, callback) {
|
||||
callback = callback || function () {};
|
||||
if (!Array.isArray(tids) || !tids.length) {
|
||||
return callback();
|
||||
}
|
||||
|
||||
tids = tids.filter(function(tid, index, array) {
|
||||
tids = tids.filter(function (tid, index, array) {
|
||||
return tid && utils.isNumber(tid) && array.indexOf(tid) === index;
|
||||
});
|
||||
|
||||
@@ -239,7 +239,7 @@ module.exports = function(Topics) {
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
tids = tids.filter(function(tid, index) {
|
||||
tids = tids.filter(function (tid, index) {
|
||||
return results.topicScores[index] && (!results.userScores[index] || results.userScores[index] < results.topicScores[index]);
|
||||
});
|
||||
|
||||
@@ -248,7 +248,7 @@ module.exports = function(Topics) {
|
||||
}
|
||||
|
||||
var now = Date.now();
|
||||
var scores = tids.map(function() {
|
||||
var scores = tids.map(function () {
|
||||
return now;
|
||||
});
|
||||
|
||||
@@ -259,9 +259,9 @@ module.exports = function(Topics) {
|
||||
}, next);
|
||||
},
|
||||
function (results, next) {
|
||||
var cids = results.topicData.map(function(topic) {
|
||||
var cids = results.topicData.map(function (topic) {
|
||||
return topic && topic.cid;
|
||||
}).filter(function(topic, index, array) {
|
||||
}).filter(function (topic, index, array) {
|
||||
return topic && array.indexOf(topic) === index;
|
||||
});
|
||||
|
||||
@@ -273,7 +273,7 @@ module.exports = function(Topics) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
Topics.markAllRead = function(uid, callback) {
|
||||
Topics.markAllRead = function (uid, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getSortedSetRevRangeByScore('topics:recent', 0, -1, '+inf', Topics.unreadCutoff(), next);
|
||||
@@ -288,19 +288,19 @@ module.exports = function(Topics) {
|
||||
], callback);
|
||||
};
|
||||
|
||||
Topics.markTopicNotificationsRead = function(tids, uid) {
|
||||
Topics.markTopicNotificationsRead = function (tids, uid) {
|
||||
if (!Array.isArray(tids) || !tids.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
function (next) {
|
||||
user.notifications.getUnreadByField(uid, 'tid', tids, next);
|
||||
},
|
||||
function(nids, next) {
|
||||
function (nids, next) {
|
||||
notifications.markReadMultiple(nids, uid, next);
|
||||
}
|
||||
], function(err) {
|
||||
], function (err) {
|
||||
if (err) {
|
||||
return winston.error(err);
|
||||
}
|
||||
@@ -308,8 +308,8 @@ module.exports = function(Topics) {
|
||||
});
|
||||
};
|
||||
|
||||
Topics.markCategoryUnreadForAll = function(tid, callback) {
|
||||
Topics.getTopicField(tid, 'cid', function(err, cid) {
|
||||
Topics.markCategoryUnreadForAll = function (tid, callback) {
|
||||
Topics.getTopicField(tid, 'cid', function (err, cid) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -318,30 +318,30 @@ module.exports = function(Topics) {
|
||||
});
|
||||
};
|
||||
|
||||
Topics.hasReadTopics = function(tids, uid, callback) {
|
||||
Topics.hasReadTopics = function (tids, uid, callback) {
|
||||
if (!parseInt(uid, 10)) {
|
||||
return callback(null, tids.map(function() {
|
||||
return callback(null, tids.map(function () {
|
||||
return false;
|
||||
}));
|
||||
}
|
||||
|
||||
async.parallel({
|
||||
recentScores: function(next) {
|
||||
recentScores: function (next) {
|
||||
db.sortedSetScores('topics:recent', tids, next);
|
||||
},
|
||||
userScores: function(next) {
|
||||
userScores: function (next) {
|
||||
db.sortedSetScores('uid:' + uid + ':tids_read', tids, next);
|
||||
},
|
||||
tids_unread: function (next) {
|
||||
db.sortedSetScores('uid:' + uid + ':tids_unread', tids, next);
|
||||
}
|
||||
}, function(err, results) {
|
||||
}, function (err, results) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var cutoff = Topics.unreadCutoff();
|
||||
var result = tids.map(function(tid, index) {
|
||||
var result = tids.map(function (tid, index) {
|
||||
return !results.tids_unread[index] &&
|
||||
(results.recentScores[index] < cutoff ||
|
||||
!!(results.userScores[index] && results.userScores[index] >= results.recentScores[index]));
|
||||
@@ -351,13 +351,13 @@ module.exports = function(Topics) {
|
||||
});
|
||||
};
|
||||
|
||||
Topics.hasReadTopic = function(tid, uid, callback) {
|
||||
Topics.hasReadTopics([tid], uid, function(err, hasRead) {
|
||||
Topics.hasReadTopic = function (tid, uid, callback) {
|
||||
Topics.hasReadTopics([tid], uid, function (err, hasRead) {
|
||||
callback(err, Array.isArray(hasRead) && hasRead.length ? hasRead[0] : false);
|
||||
});
|
||||
};
|
||||
|
||||
Topics.markUnread = function(tid, uid, callback) {
|
||||
Topics.markUnread = function (tid, uid, callback) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
Topics.exists(tid, next);
|
||||
|
||||
Reference in New Issue
Block a user