Construct room state.
Room State represents the state of the room at a given point.
It can be mutated by adding state events to it.
There are two types of room member associated with a state event:
normal member objects (accessed via getMember/getMembers) which mutate
with the state to represent the current state of that room/user, e.g.
the object returned by getMember('@bob:example.com')
will mutate to
get a different display name if Bob later changes his display name
in the room.
There are also 'sentinel' members (accessed via getSentinelMember).
These also represent the state of room members at the point in time
represented by the RoomState object, but unlike objects from getMember,
sentinel objects will always represent the room state as at the time
getSentinelMember was called, so if Bob subsequently changes his display
name, a room member object previously acquired with getSentinelMember
will still have his old display name. Calling getSentinelMember again
after the display name change will return a new RoomMember object
with Bob's new display name.
Optional. The ID of the room which has this state. If none is specified it just tracks paginationTokens, useful for notifTimelineSet
Optional. The state of loading out of bound members. As the timeline might get reset while they are loading, this state needs to be inherited and shared when the room state is cloned for the new timeline. This should only be passed from clone.
Private
_liveReadonly
beaconsPrivate
displayPrivate
invitedPrivate
joinedPrivate
modifiedPrivate
oobOptional. The state of loading out of bound members. As the timeline might get reset while they are loading, this state needs to be inherited and shared when the room state is cloned for the new timeline. This should only be passed from clone.
Readonly
reReadonly
roomOptional. The ID of the room which has this state. If none is specified it just tracks paginationTokens, useful for notifTimelineSet
Private
sentinelsPrivate
summaryPrivate
summaryPrivate
tokenPrivate
userRest
...args: Parameters<EventHandlerMap[T]>Rest
...args: Parameters<EventHandlerMap[T]>Returns the guest access based on the m.room.guest_access state event, defaulting to shared
.
the guest_access applied to this room
Returns the history visibility based on the m.room.history_visibility state event, defaulting to shared
.
the history_visibility applied to this room
Get the m.room.member event which has the given third party invite token.
The m.room.member event or null
The token
Get a room member by their user ID.
The member or null if they do not exist.
The room member's user ID.
Get all RoomMembers in this room.
A list of RoomMembers.
Get all RoomMembers in this room, excluding the user IDs provided.
A list of RoomMembers.
The user IDs to exclude.
Private
getLooks up a member by the given userId, and if it doesn't exist,
create it and emit the RoomState.newMember
event.
This method makes sure the member is added to the members dictionary
before emitting, as this is done from setStateEvents and setOutOfBandMember.
the member, existing or newly created.
Fires NewMember
the id of the user to look up
the membership event for the (new) member. Used to emit.
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.
The member or null if they do not exist.
The room member's user ID.
Private
getGet state events from the state of the room.
A list of events if state_key was
undefined
, else a single event (or null if no match found).
The event type of the state event.
Returns true if the given power level is sufficient for action
true if the given power level is sufficient
The type of power level to check
The power level of the member
Returns true if the given MatrixClient has permission to send a state
event of type stateEventType
into this room.
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.
The type of state events to test
The client to test permission for
Returns true if the given user ID has permission to send a normal
event of type eventType
into this room.
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.
The type of event to test
The user ID of the user to test permission for
Private
mayReturns true if the given user ID has permission to send a normal or state
event of type eventType
into this room.
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.
The type of event to test
The user ID of the user to test permission for
If true, tests if the user may send a state event of this type. Otherwise tests whether they may send a regular event.
Returns true if userId is in room, event is not redacted and either sender of mxEvent or has power level sufficient to redact events other than their own.
true if the given used ID can redact given event
The event to test permission for
The user ID of the user to test permission for
Returns true if the given user ID has permission to send a state
event of type stateEventType
into this room.
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.
The type of state events to test
The user ID of the user to test permission for
Returns true if the given user ID has permission to trigger notification
of type notifLevelKey
true if the given user ID has permission to trigger a notification of this type.
The level of notification to test (eg. 'room')
The user ID of the user to test permission for
Private
onOptional
event: EventEmitterEvents | EmittedEventsPrivate
setExperimental
Private
setSets a single out of band member, used by both setOutOfBandMembers and clone
membership state event
Sets the loaded out-of-band members.
array of membership state events
Private
setAdd 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. May fire "RoomStateEvent.Marker" if there are
UNSTABLE_MSC2716_MARKER
events.
a list of state events for this room.
Optional
markerFoundOptions: IMarkerFoundOptionsSet the current typing event for this room.
The typing event
Add previously unknown state events. When lazy loading members while back-paginating, the relevant room state for the timeline chunk at the end of the chunk can be set with this method.
state events to prepend
Private
updatePrivate
updatePrivate
updatePrivate
updateGenerated using TypeDoc
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.