noordstar/elm-matrix-sdk-beta/3.6.0

NOTE: the latest version is 3.6.1

Matrix.Room

Room

What is usually called a chat, a channel, a conversation or a group chat on other platforms, the term used in Matrix is a "room". A room is a conversation where a group of users talk to each other.

type alias Room =
Room

The Matrix Room type representing a room that the Matrix user has joined.

mostRecentEvents : Room -> List Event

Get a list of the most recent events sent in the room.

roomId : Room -> String

Get a room's room id. This is an opaque string that distinguishes rooms from each other.

This module exposes various functions that help you inspect various aspects of a room.

Room state

State events describe the room's current state. Using state events, you can determine various pieces of information, such as the room's name, its members and how many people have rejected your invitation to join.

name : Room -> Maybe String

Get a room's name. The room name is a human-friendly string designed to be displayed to the end-user.

Keep in mind that the room name is not unique: multiple rooms can have the same name.

topic : Room -> Maybe String

Get a room's topic. A topic is a short message detailing what is currently being discussed in the room. It can also be used as a way to display extra information about the room, which may not be suitable for the room name.

pinnedEvents : Room -> List String

Get a room's pinned events. Pinned events are event IDs that the user is expected to review later.

{ eventType : String
, stateKey : String
}
-> Room
-> Maybe Event

Get a room's current state.

Actions

{ reason : Maybe String
, room : Room
, toMsg : VaultUpdate -> msg
}
-> Cmd msg

Leave a room.

{ eventId : String
, reason : Maybe String
, room : Room
, toMsg : VaultUpdate -> msg
, transactionId : String
}
-> Cmd msg

Redact an event in the room. This erases as much information from the event as possible.

Account data

Account data is personal information that the user stores about this Matrix room. This may include information like:

  • What type of room this is
  • A list of members in the room to ignore
  • A list of currently ongoing chess matches in the room
  • Personal notes the user may be taking

You may consider the account data as a Dict String Json.Value type. Account data is linked to the user account: other logged in devices can see the account data too, as the server synchronizes it, but the server shouldn´t show it to other users.

getAccountData : String -> Room -> Maybe Value

Get a piece of account data linked to a certain string key.

{ content : Value
, eventType : String
, room : Room
, toMsg : VaultUpdate -> msg
}
-> Cmd msg

Set account data to a Matrix room.

Sending events

Besides reading the latest events, one can also send new events to the Matrix room. These events are JSON objects that can be shaped in any way or form that you like. To help other users with decoding your JSON objects, you pass an eventType string which helps them figure out the nature of your JSON object.

{ content : Value
, eventType : String
, room : Room
, toMsg : VaultUpdate -> msg
, transactionId : String
}
-> Cmd msg

Send a message event to a given room.

{ content : Value
, eventType : String
, room : Room
, stateKey : String
, toMsg : VaultUpdate -> msg
}
-> Cmd msg

Send a state event to a given room.

Moderating users

{ reason : Maybe String
, room : Room
, toMsg : VaultUpdate -> msg
, user : User
}
-> Cmd msg

Invite a user to a room.

{ reason : Maybe String
, room : Room
, toMsg : VaultUpdate -> msg
, user : User
}
-> Cmd msg

Kick a user from a room.

ban :
{ reason : Maybe String
, room : Room
, toMsg : VaultUpdate -> msg
, user : User
}
-> Cmd msg

Ban a user from a room.