This module contains all the functions necessary to view and manipulate Matrix events.
Types.Event
In Matrix, the primary form of communication is to send JSON values to one another. These JSON values, together with their metadata, are bundled into Event types. They contain information like:
content : Event -> Json.Encode.Value
Receive the body of an Event, as created by the user that sent it.
eventType : Event -> String
To give a hint what the event's content might look like, users can use this eventType value to hint at how the JSON might be decoded.
Standard examples of event types are m.room.message
, m.room.member
and
me.noordstar.game.chess.move
.
stateKey : Event -> Maybe String
Determine an event's state key.
It is present if, and only if, the event is a state event. The key makes the
piece of state unique in the room. Note that it is often Just ""
. If it is not
present, its value is Nothing
.
State keys starting with an @
are reserved for referencing user IDs, such as
room members. With the exception of a few events, state events set with a given
user'd ID as the state key can only be set by that user.
eventId : Event -> String
Determine the globally unique identifier for an event.
roomId : Event -> String
Unique id assigned to the Matrix room. You can use this room id to reference or look up rooms.
sender : Event -> Types.User
Determine the fully-qualified ID of the user who sent an event.
originServerTs : Event -> Time.Posix
Determine the timestamp of at what time the event was originally received by the original homeserver.
Generally, this timestamp offers a relatively accurate indicator of when a message was sent. However, this number isn't completely reliable! The timestamp can be far in the past due to long network lag, and a (malicious) homeserver can spoof this number to make it seem like something was sent ridiculously far in the past - or even in the future.
Occasionally, the Event might bring some extra information. Given how this information isn't always applicable, it doesn't always exist.
previousContent : Event -> Maybe Json.Encode.Value
Determine the previous content
value for this event. This field is only a
Just value
if the event is a state event, and the Matrix Vault has permission
to see the previous content.
redactedBecause : Event -> Maybe Event
If the event has been redacted, the homeserver can display the event that redacted it here.