Construct a Matrix Event object
Private
_cachedPrivate
_hasPrivate
_isPrivate
_localPrivate
_replacingPrivate
claimedPrivate
Optional
clearPrivate
decryptionPrivate
encryptedmost recent error associated with sending the event, if any
The raw (possibly encrypted) event. Do not access this property directly unless you absolutely have to. Prefer the getter methods defined on this class. Using the getter methods shields your app from changes to event JSON between Matrix versions.
True if this event is 'forward looking', meaning that getDirectionalContent() will return event.content and not event.prev_content. Only state events may be backwards looking Default: true. This property is experimental and may change.
Private
forwardingPrivate
pushPrivate
Readonly
rePrivate
retryThe room member who sent this event, or null e.g. this is a presence event. This is only guaranteed to be set for events that appear in a timeline, ie. do not guarantee that it will be set on state events.
Private
senderThe sending status of the event.
The room member who is the target of this event, e.g. the invitee, the person being banned, etc.
Private
Optional
threadA reference to the thread this event belongs to
Private
Optional
threadPrivate
Optional
txnPrivate
untrustedOptional
verificationPrivate
visibilityA helper to check if an event is a thread's head or not
Get the event ID of the thread head
Unstable getter to try and get an extensible event. Note that this might return a falsy value if the event could not be parsed as an extensible event.
Use stable functions where possible.
Alias for TypedEventEmitter#on.
Change the visibility of an event, as per https://github.com/matrix-org/matrix-doc/pull/3531 .
Optional
visibilityChange: IVisibilityChangeevent holding a hide/unhide payload, or nothing if the event is being reset to its original visibility (presumably by a visibility event being redacted).
Fires MatrixEventEvent.VisibilityChange if visibilityEvent
caused a change in the actual visibility of this event, either by making it
visible (if it was hidden), by making it hidden (if it was visible) or by
changing the reason (if it was hidden).
Return the visibility change caused by this event, as per https://github.com/matrix-org/matrix-doc/pull/3531.
If the event is a well-formed visibility change event,
an instance of IVisibilityChange
, otherwise null
.
Internal
Start the process of trying to decrypt this event.
(This is used within the SDK: it isn't intended for use by applications)
crypto module
promise which resolves (to undefined) when the decryption attempt is completed.
Private
badPrivate
decryptionSynchronously 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<MatrixEventHandlerMap[T]>Arguments to pass to the listener
true
if the event had listeners, false
otherwise.
Rest
...args: Parameters<MatrixEventHandlerMap[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<MatrixEventHandlerMap[T]>Arguments to pass to the listener
true
if the event had listeners, false
otherwise.
Rest
...args: Parameters<MatrixEventHandlerMap[T]>Flags an event as cancelled due to future conditions. For example, a verification request event in the same sync transaction may be flagged as cancelled to warn listeners that a cancellation event is coming down the same pipe shortly.
Whether the event is to be cancelled or not.
Get the age of this event. This represents the age of the event when the event arrived at the device, and not the age of the event when this function was called. Can only be returned once the server has echo'ed back
The age of this event in milliseconds.
Returns the status of any associated edit or redaction (not for reactions/annotations as their local echo doesn't affect the original event), or else the status of the event.
Get the ed25519 the sender of this event claims to own.
For Olm messages, this claim is encoded directly in the plaintext of the event itself. For megolm messages, it is implied by the m.room_key event which established the megolm session.
Until we download the device list of the sender, it's just a claim: the device list gives a proof that the owner of the curve25519 key used for this event (and returned by #getSenderKey) also owns the ed25519 key by signing the public curve25519 key with the ed25519 key.
In general, applications should not use this method directly, but should instead use CryptoApi#getEncryptionInfoForEvent.
Get either 'content' or 'prev_content' depending on if this event is 'forward-looking' or not. This can be modified via event.forwardLooking. In practice, this means we get the chronologically earlier content value for this event (this method should surely be called getEarlierContent) This method is experimental and may change.
event.content if this event is forward-looking, else event.prev_content.
Gets the event as it would appear if it had been sent unencrypted.
If the event is encrypted, we attempt to mock up an event as it would have looked had the sender not encrypted it. If the event is not encrypted, a copy of it is simply returned as-is.
A shallow copy of the event, in wire format, as it would have been had it not been encrypted.
Get the curve25519 keys of the devices which were involved in telling us about the claimedEd25519Key and sender curve25519 key.
Normally this will be empty, but in the case of a forwarded megolm session, the sender keys are sent to us by another device (the forwarding device), which we need to trust to do this. In that case, the result will be a list consisting of one entry.
If the device that sent us the key (A) got it from another device which it wasn't prepared to vouch for (B), the result will be [A, B]. And so on.
base64-encoded curve25519 keys, from oldest to newest.
Calculate the recipients for keyshare requests.
the user who received this event.
array of recipients
Get the push actions, if known, for this event
push actions
Get the push details, if known, for this event
push actions
Get relation info for the event, if any.
The curve25519 key for the device that we think sent this event
For an Olm-encrypted event, this is inferred directly from the DH exchange at the start of the session: the curve25519 key is involved in the DH exchange, so only a device which holds the private part of that key can establish such a session.
For a megolm-encrypted event, it is inferred from the Olm message which established the megolm session
Private
invalidateDetermines if this event is equivalent to the given event. This only checks the event object itself, not the other properties of the event. Intended for use with toSnapshot() to identify events changing.
The other event to check against.
True if the events are the same, false otherwise.
Check if this event alters the visibility of another event, as per https://github.com/matrix-org/matrix-doc/pull/3531.
True if this event alters the visibility of another event.
Returns the number of listeners listening to the event named event
.
The name of the event being listened for
Returns the event that wants to redact this event, but hasn't been sent yet.
the event
Internal
Replace the content of this event with encrypted versions. (This is used when sending an event; it should not be used by applications).
type of the encrypted event - typically "m.room.encrypted"
raw 'content' for the encrypted event.
curve25519 key to record for the sender of this event. See MatrixEvent#getSenderKey.
claimed ed25519 key to record for the sender if this event. See MatrixEvent#getClaimedEd25519Key
In favor of the overload that includes a Room argument
Update the content of an event in the same way it would be by the server if it were redacted before it was sent to us
event causing the redaction
the room in which the event exists
Set an event that replaces the content of this event, through an m.replace relation.
Optional
newEvent: MatrixEventthe event with the replacing content, if any.
Return instructions to display or hide the message.
Instructions determining whether the message should be displayed.
Private
movePrivate
moveAlias 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.
Adds 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.
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 | MatrixEventEmittedEventsThe 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.
Returns the event replacing the content of this event, if any. Replacements are aggregated on the server, so this would only return an event in case it came down the sync, or for local echo of edits.
Private
setInternal
Update the cleartext data on this event.
(This is used after decrypting an event; it should not be used by applications).
the decryption result, including the plaintext and some key info
Set the push actions for this event. Clears rule from push details if present
push actions
use setPushDetails
Set the push details for this event.
Optional
pushActions: IActionsObjectpush actions
Optional
rule: IAnnotatedPushRulethe executed push rule
Update the event's sending status and emit an event as well.
The new status
Set the instance of a thread associated with the current event
Optional
thread: Threadthe thread
Summarise the event as JSON.
If encrypted, include both the decrypted and encrypted view of the event.
This is named toJSON
for use with JSON.stringify
which checks objects
for functions named toJSON
and will call them to customise the output
if they are defined.
WARNING Do not log the result of this method; otherwise, it will end up in rageshakes, leading to a privacy violation.
Prefer to use MatrixEvent#getEffectiveEvent or similar. This method will be removed soon; it is too easy to use it accidentally and cause a privacy violation (cf https://github.com/vector-im/element-web/issues/26380). In any case, the value it returns is not a faithful serialization of the object.
Get a copy/snapshot of this event. The returned copy will be loosely linked back to this instance, though will have "frozen" event information. Other properties of this MatrixEvent instance will be copied verbatim, which can mean they are in reference to this instance despite being on the copy too. The reference the snapshot uses does not change, however members aside from the underlying event will not be deeply cloned, thus may be mutated internally. For example, the sender profile will be copied over at snapshot time, and the sender profile internally may mutate without notice to the consumer.
This is meant to be used to snapshot the event details themselves, not the features (such as sender) surrounding the event.
A snapshot of this event.
Generated 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
?