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
userAlias for TypedEventEmitter#on.
Synchronously calls each of the listeners registered for the event named
event
, in the order they were registered, passing the supplied arguments
to each.
The name of the event to emit
Rest
...args: Parameters<EventHandlerMap[T]>Arguments to pass to the listener
true
if the event had listeners, false
otherwise.
Rest
...args: Parameters<EventHandlerMap[T]>Similar to emit
but calls all listeners within a Promise.all
and returns the promise chain
The name of the event to emit
Rest
...args: Parameters<EventHandlerMap[T]>Arguments to pass to the listener
true
if the event had listeners, false
otherwise.
Rest
...args: Parameters<EventHandlerMap[T]>Find the predecessor room based on this room state.
if true, look for an m.room.predecessor state event and use it if found (MSC3946).
null if this room has no predecessor. Otherwise, returns the roomId, last eventId and viaServers of the predecessor room.
If msc3946ProcessDynamicPredecessor is true, use m.predecessor events as well as m.room.create events to find predecessors.
Note: if an m.predecessor event is used, eventId may be undefined since last_known_event_id is optional.
Note: viaServers may be undefined, and will definitely be undefined if this predecessor comes from a RoomCreate event (rather than a RoomPredecessor, which has the optional via_servers property).
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 token
The m.room.member event or null
Get a room member by their user ID.
The room member's user ID.
The member or null if they do not exist.
Get all RoomMembers in this room.
A list of RoomMembers.
Get all RoomMembers in this room, excluding the user IDs provided.
The user IDs to exclude.
A list of RoomMembers.
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 id of the user to look up
the membership event for the (new) member. Used to emit.
the member, existing or newly created.
Fires RoomStateEvent.NewMember
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 room member's user ID.
The member or null if they do not exist.
Private
getGet state events from the state of the room.
The event type of the state event.
A list of events
Get state events from the state of the room.
The event type of the state event.
The state_key of the state event.
A single event (or null if no match found).
Returns true if the given power level is sufficient for action
The type of power level to check
The power level of the member
true if the given power level is sufficient
Returns the number of listeners listening to the event named event
.
The name of the event being listened for
Returns a copy of the array of listeners for the event named event
.
Returns true if the given MatrixClient has permission to send a state
event of type stateEventType
into this room.
The type of state events to test
The client to test permission for
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.
Returns true if the given user ID has permission to send a normal
event of type eventType
into this room.
The type of event to test
The user ID of the user to test permission for
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.
Private
mayReturns true if the given user ID has permission to send a normal or state
event of type eventType
into this room.
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.
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.
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.
The event to test permission for
The user ID of the user to test permission for
true if the given used ID can redact given event
Returns true if the given user ID has permission to send a state
event of type stateEventType
into this room.
The type of state events to test
The user ID of the user to test permission for
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.
Returns true if the given user ID has permission to trigger notification
of type notifLevelKey
The level of notification to test (eg. 'room')
The user ID of the user to test permission for
true if the given user ID has permission to trigger a notification of this type.
Alias for TypedEventEmitter#removeListener
Adds the listener
function to the end of the listeners array for the
event named event
.
No checks are made to see if the listener
has already been added. Multiple calls
passing the same combination of event
and listener
will result in the listener
being added, and called, multiple times.
By default, event listeners are invoked in the order they are added. The TypedEventEmitter#prependListener method can be used as an alternative to add the event listener to the beginning of the listeners array.
The name of the event.
The callback function
a reference to the EventEmitter
, so that calls can be chained.
Private
onAdds a one-time listener
function for the event named event
. The
next time event
is triggered, this listener is removed and then invoked.
Returns a reference to the EventEmitter
, so that calls can be chained.
By default, event listeners are invoked in the order they are added. The TypedEventEmitter#prependOnceListener method can be used as an alternative to add the event listener to the beginning of the listeners array.
The name of the event.
The callback function
a reference to the EventEmitter
, so that calls can be chained.
Adds the listener
function to the beginning of the listeners array for the
event named event
.
No checks are made to see if the listener
has already been added. Multiple calls
passing the same combination of event
and listener
will result in the listener
being added, and called, multiple times.
The name of the event.
The callback function
a reference to the EventEmitter
, so that calls can be chained.
Adds a one-timelistener
function for the event named event
to the beginning of the listeners array.
The next time event
is triggered, this listener is removed, and then invoked.
The name of the event.
The callback function
a reference to the EventEmitter
, so that calls can be chained.
Returns a copy of the array of listeners for the event named eventName
,
including any wrappers (such as those created by .once()
).
Removes all listeners, or those of the specified event
.
It is bad practice to remove listeners added elsewhere in the code,
particularly when the EventEmitter
instance was created by some other
component or module (e.g. sockets or file streams).
Optional
event: EventEmitterEvents | EmittedEventsThe name of the event. If undefined, all listeners everywhere are removed.
a reference to the EventEmitter
, so that calls can be chained.
Removes the specified listener
from the listener array for the event named event
.
a reference to the EventEmitter
, so that calls can be chained.
Private
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: IMarkerFoundOptionsFires RoomStateEvent.Members Fires RoomStateEvent.NewMember Fires RoomStateEvent.Events Fires RoomStateEvent.Marker
Set 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.
Type parameters:
Events
- List of all events emitted by thisTypedEventEmitter
. Normally an enum type.Arguments
- A ListenerMap type providing mappings from event names to listener types.SuperclassArguments
- TODO: not really sure. Alternative listener mappings, I think? But only honoured for.emit
?