Skip to content

Node.js based forum software built for the modern web

feat: closes #10324, show recently online users as well

Barış Soner Uşaklıeac9cd03ca27
diff --git a/src/controllers/users.js b/src/controllers/users.js
index 818cb86123..ee57bf1afe 100644
--- a/src/controllers/users.js
+++ b/src/controllers/users.js
@@ -148,14 +148,22 @@ usersController.getUsers = async function (set, uid, query) {
usersController.getUsersAndCount = async function (set, uid, start, stop) {
async function getCount() {
if (set === 'users:online') {
- return await db.sortedSetCount('users:online', Date.now() - (meta.config.onlineCutoff * 60000), '+inf');
+ return await db.sortedSetCount('users:online', Date.now() - 86400000, '+inf');
} else if (set === 'users:banned' || set === 'users:flags') {
return await db.sortedSetCard(set);
}
return await db.getObjectField('global', 'userCount');
}
+ async function getUsers() {
+ if (set === 'users:online') {
+ const count = parseInt(stop, 10) === -1 ? stop : stop - start + 1;
+ const uids = await db.getSortedSetRevRangeByScore(set, start, count, '+inf', Date.now() - 86400000);
+ return await user.getUsers(uids, uid);
+ }
+ return await user.getUsersFromSet(set, uid, start, stop);
+ }
const [usersData, count] = await Promise.all([
- user.getUsersFromSet(set, uid, start, stop),
+ getUsers(),
getCount(),
]);
return {