Skip to content

Node.js based forum software built for the modern web

fix: fire action:user.online on user login

Barış Soner Uşaklı7397873db355
diff --git a/src/controllers/authentication.js b/src/controllers/authentication.js
index 82dc6b1660..bb6e6bf49f 100644
--- a/src/controllers/authentication.js
+++ b/src/controllers/authentication.js
@@ -383,7 +383,7 @@ authenticationController.onSuccessfulLogin = async function (req, uid) {
}),
user.auth.addSession(uid, req.sessionID),
user.updateLastOnlineTime(uid),
- user.updateOnlineUsers(uid),
+ user.onUserOnline(uid, Date.now()),
analytics.increment('logins'),
db.incrObjectFieldBy('global', 'loginCount', 1),
]);
diff --git a/src/user/online.js b/src/user/online.js
index ffba4c9a94..b7c6b9d45a 100644
--- a/src/user/online.js
+++ b/src/user/online.js
@@ -27,9 +27,13 @@ module.exports = function (User) {
if (now - parseInt(userOnlineTime, 10) < 300000) {
return;
}
- await db.sortedSetAdd('users:online', now, uid);
+ await User.onUserOnline(uid, now);
topics.pushUnreadCount(uid);
- plugins.hooks.fire('action:user.online', { uid: uid, timestamp: now });
+ };
+
+ User.onUserOnline = async (uid, timestamp) => {
+ await db.sortedSetAdd('users:online', timestamp, uid);
+ plugins.hooks.fire('action:user.online', { uid, timestamp });
};
User.isOnline = async function (uid) {