Class: User

module:models/user~User

new User(userId)

Construct a new User. A User must have an ID and can optionally have extra information associated with it.
Parameters:
Name Type Description
userId string Required. The ID of this user.
Properties:
Name Type Description
userId string The ID of the user.
info Object The info object supplied in the constructor.
displayName string The 'displayname' of the user if known.
avatarUrl string The 'avatar_url' of the user if known.
presence string The presence enum if known.
presenceStatusMsg string The presence status message if known.
lastActiveAgo Number The time elapsed in ms since the user interacted proactively with the server, or we saw a message from the user
lastPresenceTs Number Timestamp (ms since the epoch) for when we last received presence data for this user. We can subtract lastActiveAgo from this to approximate an absolute value for when a user was last active.
currentlyActive Boolean Whether we should consider lastActiveAgo to be an approximation and that the user should be seen as active 'now'
events Object The events describing this user.
Properties
Name Type Description
presence MatrixEvent The m.presence event for this user.
Source:

Methods

_updateModifiedTime()

Update the last modified time to the current time.
Source:

getLastActiveTs() → {number}

Get the absolute timestamp when this User was last known active on the server. It is *NOT* accurate if this.currentlyActive is true.
Source:
Returns:
The timestamp
Type
number

getLastModifiedTime() → {number}

Get the timestamp when this User was last updated. This timestamp is updated when this User receives a new Presence event which has updated a property on this object. It is updated before firing events.
Source:
Returns:
The timestamp
Type
number

setAvatarUrl(url)

Manually set this user's avatar URL. No event is emitted in response to this as there is no underlying MatrixEvent to emit with.
Parameters:
Name Type Description
url string The new avatar URL.
Source:

setDisplayName(name)

Manually set this user's display name. No event is emitted in response to this as there is no underlying MatrixEvent to emit with.
Parameters:
Name Type Description
name string The new display name.
Source:

setPresenceEvent(event)

Update this User with the given presence event. May fire "User.presence", "User.avatarUrl" and/or "User.displayName" if this event updates this user's properties.
Parameters:
Name Type Description
event MatrixEvent The m.presence event.
Source:
Fires:
  • module:client~MatrixClient#event:"User.presence"
  • module:client~MatrixClient#event:"User.displayName"
  • module:client~MatrixClient#event:"User.avatarUrl"

setRawDisplayName(name)

Manually set this user's non-disambiguated display name. No event is emitted in response to this as there is no underlying MatrixEvent to emit with.
Parameters:
Name Type Description
name string The new display name.
Source: