Class User

Typed Event Emitter class which can act as a Base Model for all our model and communication events. This makes it much easier for us to distinguish between events, as we now need to properly type this, so that our events are not stringly-based and prone to silly typos.

Hierarchy

Constructors

  • Construct a new User. A User must have an ID and can optionally have extra information associated with it.

    Prop

    The ID of the user.

    Prop

    The info object supplied in the constructor.

    Prop

    The 'displayname' of the user if known.

    Prop

    The 'avatar_url' of the user if known.

    Prop

    The presence enum if known.

    Prop

    The presence status message if known.

    Prop

    The time elapsed in ms since the user interacted proactively with the server, or we saw a message from the user

    Prop

    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.

    Prop

    Whether we should consider lastActiveAgo to be an approximation and that the user should be seen as active 'now'

    Prop

    The events describing this user.

    Prop

    The m.presence event for this user.

    Parameters

    • userId: string

      Required. The ID of this user.

    Returns User

Properties

avatarUrl?: string
currentlyActive: boolean = false
displayName?: string
events: {
    presence?: MatrixEvent;
    profile?: MatrixEvent;
} = {}

Type declaration

lastActiveAgo: number = 0
lastPresenceTs: number = 0
modified: number = -1
presence: string = "offline"
presenceStatusMsg?: string
rawDisplayName?: string
userId: string

Required. The ID of this user.

Methods

  • Get the absolute timestamp when this User was last known active on the server. It is NOT accurate if this.currentlyActive is true.

    Returns

    The timestamp

    Returns 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.

    Returns

    The timestamp

    Returns number

  • 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

    • Optional url: string

      The new avatar URL.

    Returns void

  • 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: string

      The new display name.

    Returns void

  • 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.

    Fires

    module:client~MatrixClient#event:"User.presence"

    Fires

    module:client~MatrixClient#event:"User.displayName"

    Fires

    module:client~MatrixClient#event:"User.avatarUrl"

    Parameters

    Returns void

  • 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

    • Optional name: string

      The new display name.

    Returns void

  • Update the last modified time to the current time.

    Returns void

Generated using TypeDoc