POC: Add LastSeenManager to batch user activity updates

This commit is contained in:
Vito0912 2025-06-28 20:04:31 +02:00
parent d21fe49ce2
commit 0749a55deb
No known key found for this signature in database
GPG key ID: 29A3D509FE70B237
3 changed files with 144 additions and 4 deletions

View file

@ -269,9 +269,11 @@ class SocketAuthority {
this.adminEmitter('user_online', client.user.toJSONForPublic(this.Server.playbackSessionManager.sessions))
// Update user lastSeen without firing sequelize bulk update hooks
user.lastSeen = Date.now()
await user.save({ hooks: false })
if (this.Server.lastSeenManager) {
this.Server.lastSeenManager.addActiveUser(user.id)
// To ensure actual lastSeen behaviour does not change, we just flush when connecting. This should not add much overhead as this is only for the authenticated socket.
this.Server.lastSeenManager.flushActiveUsers()
}
const initialPayload = {
userId: client.user.id,