Class: RoomState

module:models/room-state~RoomState

new RoomState(roomIdnullable)

Construct room state.
Parameters:
Name Type Attributes Description
roomId string <nullable>
Optional. The ID of the room which has this state. If none is specified it just tracks paginationTokens, useful for notifTimelineSet
Properties:
Name Type Description
members Object.<string, RoomMember> The room member dictionary, keyed on the user's ID.
events Object.<string, Object.<string, MatrixEvent>> The state events dictionary, keyed on the event type and then the state_key value.
paginationToken string The pagination token for this state.
Source:

Methods

_maySendEventOfType(type, userId, state) → {boolean}

Returns true if the given user ID has permission to send a normal or state event of type `eventType` into this room.
Parameters:
Name Type Description
type string The type of event to test
userId string The user ID of the user to test permission for
state boolean If true, tests if the user may send a state event of this type. Otherwise tests whether they may send a regular event.
Source:
Returns:
true if the given user ID should be permitted to send the given type of event into this room, according to the room's state.
Type
boolean

_updateModifiedTime()

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

getInviteForThreePidToken(token) → (nullable) {MatrixEvent}

Get the m.room.member event which has the given third party invite token.
Parameters:
Name Type Description
token string The token
Source:
Returns:
The m.room.member event or null
Type
MatrixEvent

getLastModifiedTime() → {number}

Get the timestamp when this room state was last updated. This timestamp is updated when this object has received new state events.
Source:
Returns:
The timestamp
Type
number

getMember(userId) → {RoomMember}

Get a room member by their user ID.
Parameters:
Name Type Description
userId string The room member's user ID.
Source:
Returns:
The member or null if they do not exist.
Type
RoomMember

getMembers() → {Array.<RoomMember>}

Get all RoomMembers in this room.
Source:
Returns:
A list of RoomMembers.
Type
Array.<RoomMember>

getSentinelMember(userId) → {RoomMember}

Get a room member whose properties will not change with this room state. You typically want this if you want to attach a RoomMember to a MatrixEvent which may no longer be represented correctly by Room.currentState or Room.oldState. The term 'sentinel' refers to the fact that this RoomMember is an unchanging guardian for state at this particular point in time.
Parameters:
Name Type Description
userId string The room member's user ID.
Source:
Returns:
The member or null if they do not exist.
Type
RoomMember

getStateEvents(eventType, stateKey) → {Array.<MatrixEvent>|MatrixEvent}

Get state events from the state of the room.
Parameters:
Name Type Description
eventType string The event type of the state event.
stateKey string Optional. The state_key of the state event. If this is undefined then all matching state events will be returned.
Source:
Returns:
A list of events if state_key was undefined, else a single event (or null if no match found).
Type
Array.<MatrixEvent> | MatrixEvent

getUserIdsWithDisplayName(displayName) → {Array.<string>}

Get user IDs with the specified display name.
Parameters:
Name Type Description
displayName string The display name to get user IDs from.
Source:
Returns:
An array of user IDs or an empty array.
Type
Array.<string>

mayClientSendStateEvent(type, The) → {boolean}

Returns true if the given MatrixClient has permission to send a state event of type `stateEventType` into this room.
Parameters:
Name Type Description
type string The type of state events to test
The MatrixClient client to test permission for
Source:
Returns:
true if the given client should be permitted to send the given type of state event into this room, according to the room's state.
Type
boolean

maySendEvent(type, userId) → {boolean}

Returns true if the given user ID has permission to send a normal event of type `eventType` into this room.
Parameters:
Name Type Description
type string The type of event to test
userId string The user ID of the user to test permission for
Source:
Returns:
true if the given user ID should be permitted to send the given type of event into this room, according to the room's state.
Type
boolean

maySendMessage(userId) → {boolean}

Short-form for maySendEvent('m.room.message', userId)
Parameters:
Name Type Description
userId string The user ID of the user to test permission for
Source:
Returns:
true if the given user ID should be permitted to send message events into the given room.
Type
boolean

maySendStateEvent(type, userId) → {boolean}

Returns true if the given user ID has permission to send a state event of type `stateEventType` into this room.
Parameters:
Name Type Description
type string The type of state events to test
userId string The user ID of the user to test permission for
Source:
Returns:
true if the given user ID should be permitted to send the given type of state event into this room, according to the room's state.
Type
boolean

setStateEvents(stateEvents)

Add an array of one or more state MatrixEvents, overwriting any existing state with the same {type, stateKey} tuple. Will fire "RoomState.events" for every event added. May fire "RoomState.members" if there are m.room.member events.
Parameters:
Name Type Description
stateEvents Array.<MatrixEvent> a list of state events for this room.
Source:
Fires:
  • module:client~MatrixClient#event:"RoomState.members"
  • module:client~MatrixClient#event:"RoomState.newMember"
  • module:client~MatrixClient#event:"RoomState.events"

setTypingEvent(event)

Set the current typing event for this room.
Parameters:
Name Type Description
event MatrixEvent The typing event
Source: