From 0e606c6fe29e33efefefbd0d8aa46cb17d9f8bb2 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Mon, 18 Apr 2016 14:26:59 +0100 Subject: [PATCH] incorporate PR feedback --- lib/models/room.js | 9 +++------ lib/models/user.js | 9 +++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/models/room.js b/lib/models/room.js index ece164ebd..52f6ca403 100644 --- a/lib/models/room.js +++ b/lib/models/room.js @@ -696,15 +696,12 @@ Room.prototype._addLiveEvent = function(event, duplicateStrategy) { event.sender.userId, event, "m.read" ), true); - // also, any live events from a user should be taken as implicit + // Any live events from a user could be taken as implicit // presence information: evidence that they are currently active. // ...except in a world where we use 'user.currentlyActive' to reduce // presence spam, this isn't very useful - we'll get a transition when - // they are no longer currently active anyway. so comment it out for now. - - // var user = this.currentState.getMember(events[i].sender.userId); - // user.lastActiveAgo = 0; - // user.lastPresenceTs = Date.now(); + // they are no longer currently active anyway. So don't bother to + // reset the lastActiveAgo and lastPresenceTs from the RoomState's user. } }; diff --git a/lib/models/user.js b/lib/models/user.js index 152182339..11ac274f6 100644 --- a/lib/models/user.js +++ b/lib/models/user.js @@ -143,6 +143,15 @@ User.prototype.getLastModifiedTime = function() { return this._modified; }; +/** + * Get the absolute timestamp when this User was last known active on the server. + * It is *NOT* accurate if this.currentlyActive is true. + * @return {number} The timestamp + */ +User.prototype.getLastActiveTs = function() { + return this.lastPresenceTs - this.lastActiveAgo; +}; + /** * The User class. */