Class: MatrixEvent

models/event.MatrixEvent

new MatrixEvent(event, clearEventopt, keysProvedopt, keysClaimedopt)

Construct a Matrix Event object
Parameters:
Name Type Attributes Description
event Object The raw event to be wrapped in this DAO
clearEvent Object <optional>
For encrypted events, the plaintext payload for the event (typically containing type and content fields).
keysProved Object <optional>
Keys owned by the sender of this event. See module:models/event.MatrixEvent#getKeysProved.
keysClaimed Object <optional>
Keys the sender of this event claims. See module:models/event.MatrixEvent#getKeysClaimed.
Properties:
Name Type Description
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.
sender RoomMember The room member who sent this event, or null e.g. this is a presence event.
target RoomMember The room member who is the target of this event, e.g. the invitee, the person being banned, etc.
status EventStatus The sending status of the event.
forwardLooking boolean True if this event is 'forward looking', meaning that getDirectionalContent() will return event.content and not event.prev_content. Default: true. This property is experimental and may change.
Source:

Methods

getAge() → {Number}

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.
Source:
Returns:
The age of this event in milliseconds.
Type
Number

getContent() → {Object}

Get the (decrypted, if necessary) event content JSON.
Source:
Returns:
The event content JSON, or an empty object.
Type
Object

getDirectionalContent() → {Object}

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.
Source:
Returns:
event.content if this event is forward-looking, else event.prev_content.
Type
Object

getId() → {string}

Get the event_id for this event.
Source:
Returns:
The event ID, e.g. $143350589368169JsLZx:localhost
Type
string

getKeysClaimed() → {Object.<string, string>}

The additional keys the sender of this encrypted event claims to possess.

These don't necessarily have to come from this event itself, but may be implied by the cryptographic session. For example megolm messages don't claim keys directly, but instead inherit a claim from the olm message that established the session.

Source:
Returns:
Type
Object.<string, string>

getKeysProved() → {Object.<string, string>}

The keys that must have been owned by the sender of this encrypted event.

These don't necessarily have to come from this event itself, but may be implied by the cryptographic session.

Source:
Returns:
Type
Object.<string, string>

getPrevContent() → {Object}

Get the previous event content JSON. This will only return something for state events which exist in the timeline.
Source:
Returns:
The previous event content JSON, or an empty object.
Type
Object

getPushActions() → (nullable) {Object}

Get the push actions, if known, for this event
Source:
Returns:
push actions
Type
Object

getRoomId() → {string}

Get the room_id for this event. This will return undefined for m.presence events.
Source:
Returns:
The room ID, e.g. !cURbafjkfsMDVwdRDQ:matrix.org
Type
string

getSender() → {string}

Get the user_id for this event.
Source:
Returns:
The user ID, e.g. @alice:matrix.org
Type
string

getSenderKey() → {string}

The curve25519 key that sent this event
Source:
Returns:
Type
string

getStateKey() → {string}

Get the event state_key if it has one. This will return undefined for message events.
Source:
Returns:
The event's state_key.
Type
string

getTs() → {Number}

Get the timestamp of this event.
Source:
Returns:
The event timestamp, e.g. 1433502692297
Type
Number

getType() → {string}

Get the (decrypted, if necessary) type of event.
Source:
Returns:
The event type, e.g. m.room.message
Type
string

getWireContent() → {Object}

Get the (possibly encrypted) event content JSON that will be sent to the homeserver.
Source:
Returns:
The event content JSON, or an empty object.
Type
Object

getWireType() → {string}

Get the (possibly encrypted) type of the event that will be sent to the homeserver.
Source:
Returns:
The event type.
Type
string

isEncrypted() → {boolean}

Check if the event is encrypted.
Source:
Returns:
True if this event is encrypted.
Type
boolean

isRedacted() → {boolean}

Check if this event has been redacted
Source:
Returns:
True if this event has been redacted
Type
boolean

isState() → {boolean}

Check if this event is a state event.
Source:
Returns:
True if this is a state event.
Type
boolean

makeEncrypted(crypto_type, crypto_content, keys)

Replace the content of this event with encrypted versions. (This is used when sending an event; it should not be used by applications).
Parameters:
Name Type Description
crypto_type string type of the encrypted event - typically "m.room.encrypted"
crypto_content object raw 'content' for the encrypted event.
keys object The local keys claimed and proved by this event.
Source:

makeRedacted(redaction_event)

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
Parameters:
Name Type Description
redaction_event module:models/event.MatrixEvent event causing the redaction
Source:

setPushActions(pushActions)

Set the push actions for this event.
Parameters:
Name Type Description
pushActions Object push actions
Source: