Construct a Matrix Event object
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.
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.
Change the visibility of an event, as per https://github.com/matrix-org/matrix-doc/pull/3531 .
Fires 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).
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).
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)
promise which resolves (to undefined) when the decryption attempt is completed.
crypto module
Private
badCancel any room key request for this event and resend another.
a promise that resolves when the request is queued
crypto module
the user who received this event
Private
decryptionRest
...args: Parameters<MatrixEventHandlerMap[T]>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 MatrixClient.getEventSenderDeviceInfo.
Get a string containing details of this event
This is intended for logging, to help trace errors. Example output:
id=$HjnOHV646n0SjLDAqFrgIjim7RCpB7cdMXFrekWYAn type=m.room.encrypted
sender=@user:example.com room=!room:example.com ts=2022-10-25T17:30:28.404Z
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.
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.
array of recipients
the user who received this event.
Get the (decrypted, if necessary) event content JSON, even if the event was replaced by another event.
The event content JSON, or an empty object.
Get the push actions, 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.
True if the events are the same, false otherwise.
The other event to check against.
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 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 getSenderKey.
claimed ed25519 key to record for the sender if this event. See getClaimedEd25519Key
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
Set an event that replaces the content of this event, through an m.replace relation.
Fires Replaced
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.
Optional
event: EventEmitterEvents | MatrixEventEmittedEventsReturns 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).
Fires Decrypted
the decryption result, including the plaintext and some key info
Set the push actions for this event.
push actions
Update the event's sending status and emit an event as well.
The new status
Summarise the event as JSON. This is currently used by React SDK's view event source feature and Seshat's event indexing, so take care when adjusting the output here.
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.
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.