Improve Event documentation

3-event
Bram 2023-12-22 22:20:19 +01:00
parent ce83d1260f
commit 0448b74609
1 changed files with 17 additions and 15 deletions

View File

@ -84,9 +84,7 @@ age envelope =
envelope envelope
{-| The Matrix protocol revolves around users being able to send each other {-| Determine the body of this event, as created by the user that sent it.
JSON objects. This function reveals the JSON value that the user has sent to
the room.
-} -}
content : Event -> E.Value content : Event -> E.Value
content = content =
@ -153,8 +151,7 @@ encodeUnsignedData (UnsignedData data) =
] ]
{-| Every event is assigned a unique id in the room. You can use this event id {-| Determine the globally unique identifier for an event.
to reference or look up events.
-} -}
eventId : Event -> String eventId : Event -> String
eventId = eventId =
@ -173,10 +170,10 @@ eventType =
Envelope.extract .eventType Envelope.extract .eventType
{-| Timestamp of at what time the event was originally received by the original {-| Determine the timestamp of at what time the event was originally received by
homeserver. the original homeserver.
Generally, this timestamp offers a relalatively accurate indicator of when a Generally, this timestamp offers a relatively accurate indicator of when a
message was sent. However, this number isn't completely reliable! The timestamp 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 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 spoof this number to make it seem like something was sent ridiculously far in
@ -188,7 +185,9 @@ originServerTs =
Envelope.extract .originServerTs Envelope.extract .originServerTs
{-| Get the old content, if the event has changed or it has been edited. {-| 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.
-} -}
prevContent : Event -> Maybe E.Value prevContent : Event -> Maybe E.Value
prevContent envelope = prevContent envelope =
@ -223,19 +222,22 @@ roomId =
Envelope.extract .roomId Envelope.extract .roomId
{-| User id of the user that sent this event. You can use this user id to {-| Determine the fully-qualified ID of the user who sent an event.
reference or look up users.
-} -}
sender : Event -> String sender : Event -> String
sender = sender =
Envelope.extract .sender Envelope.extract .sender
{-| When an event's state key is `Nothing`, it is an ordinary message event in {-| Determine an event's state key.
the timeline.
When the state key is `Just ""` or some other `Just string`, then it is a state It is present if, and only if, the event is a _state_ event. The key makes the
event that affects how the room works. TODO: Explain state events. 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.
-} -}
stateKey : Event -> Maybe String stateKey : Event -> Maybe String