libkazv
|
Represent a Matrix room. More...
#include <room.hpp>
Classes | |
struct | InEventLoopTag |
Public Types | |
using | PromiseT = SingleTypePromise< DefaultRetType > |
using | DepsT = lager::deps< SdkModelCursorKey, RandomInterface & > |
using | ContextT = Context< ClientAction > |
Public Member Functions | |
Room (lager::reader< SdkModel > sdk, lager::reader< std::string > roomId, ContextT ctx) | |
Constructor. More... | |
Room (lager::reader< SdkModel > sdk, lager::reader< std::string > roomId, ContextT ctx, DepsT deps) | |
Constructor. More... | |
Room (InEventLoopTag, std::string roomId, ContextT ctx, DepsT deps) | |
Construct a Room in the same thread as the event loop. More... | |
Room | toEventLoop () const |
Return a Room that represents the room currently represented by this, but suitable for use in the event loop of the context. More... | |
auto | stateEvents () const |
auto | inviteState () const -> lager::reader< immer::map< KeyOfState, Event >> |
Get the invite_state of this room. More... | |
auto | stateOpt (KeyOfState k) const |
auto | state (KeyOfState k) const |
auto | timelineEventIds () const -> lager::reader< immer::flex_vector< std::string >> |
Get the timeline event ids of this room in ascending timestamp order. More... | |
auto | messagesMap () const -> lager::reader< immer::map< std::string, Event >> |
Get a map from event ids to events. More... | |
auto | timelineEvents () const -> lager::reader< immer::flex_vector< Event >> |
Get a list of timeline events in this room. More... | |
auto | message (lager::reader< std::string > eventId) const -> lager::reader< Event > |
Get one message by the event id. More... | |
auto | localEcho (lager::reader< std::string > txnId) const -> lager::reader< LocalEchoDesc > |
Get one local echo by the txnId. More... | |
auto | heroMemberEvents () const -> lager::reader< immer::flex_vector< Event >> |
Get the member events of heroes this room. More... | |
auto | heroDisplayNames () const -> lager::reader< immer::flex_vector< std::string >> |
Get the member events of heroes this room. More... | |
auto | nameOpt () const -> lager::reader< std::optional< std::string >> |
Get the name of this room. More... | |
auto | name () const -> lager::reader< std::string > |
Get the name of this room. More... | |
auto | avatarMxcUri () const -> lager::reader< std::string > |
Get the avatar mxc uri of this room. More... | |
auto | members () const -> lager::reader< immer::flex_vector< std::string >> |
Get the list of joined member ids. More... | |
auto | invitedMembers () const -> lager::reader< immer::flex_vector< std::string >> |
Get the list of invited member ids. More... | |
auto | knockedMembers () const -> lager::reader< immer::flex_vector< std::string >> |
Get the list of knocked member ids. More... | |
auto | leftMembers () const -> lager::reader< immer::flex_vector< std::string >> |
Get the list of left member ids. More... | |
auto | bannedMembers () const -> lager::reader< immer::flex_vector< std::string >> |
Get the list of banned member ids. More... | |
auto | joinedMemberEvents () const -> lager::reader< EventList > |
Get the list of joined member events. More... | |
auto | invitedMemberEvents () const -> lager::reader< EventList > |
Get the list of invited member events. More... | |
auto | knockedMemberEvents () const -> lager::reader< EventList > |
Get the list of knocked member events. More... | |
auto | leftMemberEvents () const -> lager::reader< EventList > |
Get the list of left member events. More... | |
auto | bannedMemberEvents () const -> lager::reader< EventList > |
Get the list of banned member events. More... | |
auto | memberEventByCursor (lager::reader< std::string > userId) const -> lager::reader< Event > |
Get the member event for userId. More... | |
auto | memberEventFor (std::string userId) const -> lager::reader< Event > |
Get the member event for userId. More... | |
lager::reader< bool > | encrypted () const |
Get whether this room is encrypted. More... | |
KAZV_WRAP_ATTR (RoomModel, roomCursor(), roomId) | |
KAZV_WRAP_ATTR (RoomModel, roomCursor(), membership) | |
KAZV_WRAP_ATTR (RoomModel, roomCursor(), localDraft) | |
KAZV_WRAP_ATTR (RoomModel, roomCursor(), membersFullyLoaded) | |
auto | localReadMarker () const -> lager::reader< std::string > |
Get the local read marker in this room. More... | |
auto | heroIds () const -> lager::reader< immer::flex_vector< std::string >> |
Get the ids of the heroes of the room. More... | |
auto | joinedMemberCount () const -> lager::reader< std::size_t > |
Get the joined member count of this room. More... | |
auto | invitedMemberCount () const -> lager::reader< std::size_t > |
Get the invited member count of this room. More... | |
PromiseT | setLocalDraft (std::string localDraft) const |
Set local draft for this room. More... | |
PromiseT | sendMessage (Event msg) const |
Send an event to this room. More... | |
PromiseT | sendTextMessage (std::string text) const |
Send a text message to this room. More... | |
PromiseT | resendMessage (std::string txnId) const |
Resend an event to this room. More... | |
PromiseT | redactEvent (std::string eventId, std::optional< std::string > reason) const |
Redact an event. More... | |
PromiseT | sendPendingKeyEvent (std::string txnId) const |
Send one pending key event in this room. More... | |
PromiseT | sendAllPendingKeyEvents () const |
Send all pending key events in this room. More... | |
PromiseT | refreshRoomState () const |
Get the full state of this room. More... | |
PromiseT | getStateEvent (std::string type, std::string stateKey) const |
Get one state event with type and stateKey . More... | |
PromiseT | sendStateEvent (Event state) const |
Send a state event to this room. More... | |
PromiseT | setName (std::string name) const |
Set the room name. More... | |
auto | topic () const |
PromiseT | setTopic (std::string topic) const |
Set the room topic. More... | |
PromiseT | invite (std::string userId) const |
Invite a user to this room. More... | |
auto | ephemeralEvents () const |
auto | ephemeralOpt (std::string type) const |
auto | ephemeral (std::string type) const |
auto | typingUsers () const -> lager::reader< immer::flex_vector< std::string >> |
Get the ids of all typing users in this room. More... | |
auto | typingMemberEvents () const -> lager::reader< EventList > |
Get the member events of all typing users in this room. More... | |
PromiseT | setTyping (bool typing, std::optional< int > timeoutMs) const |
Set the typing status of the current user in this room. More... | |
auto | accountDataEvents () const |
auto | accountDataOpt (std::string type) const |
auto | accountData (std::string type) const |
auto | readMarker () const |
PromiseT | setAccountData (Event accountDataEvent) const |
Set the account data for this room. More... | |
auto | tags () const -> lager::reader< immer::map< std::string, double >> |
Get the tags of the current room. More... | |
PromiseT | addOrSetTag (std::string tagId, std::optional< double > order=std::nullopt) const |
Add or set a tag to this room. More... | |
PromiseT | removeTag (std::string tagId) const |
Remove a tag from this room. More... | |
PromiseT | leave () const |
Leave this room. More... | |
PromiseT | forget () const |
Forget this room. More... | |
PromiseT | kick (std::string userId, std::optional< std::string > reason=std::nullopt) const |
Kick a user from this room. More... | |
PromiseT | ban (std::string userId, std::optional< std::string > reason=std::nullopt) const |
Ban a user from this room. More... | |
PromiseT | unban (std::string userId) const |
Unban a user from this room. More... | |
auto | avatar () const |
auto | pinnedEvents () const -> lager::reader< immer::flex_vector< std::string >> |
Get pinned events of this room. More... | |
PromiseT | setPinnedEvents (immer::flex_vector< std::string > eventIds) const |
Set pinned events of this room. More... | |
PromiseT | pinEvents (immer::flex_vector< std::string > eventIds) const |
Add eventIds to the pinned events of this room. More... | |
PromiseT | unpinEvents (immer::flex_vector< std::string > eventIds) const |
Remove eventIds from the pinned events of this room. More... | |
lager::reader< immer::map< std::string, std::string > > | timelineGaps () const |
Get the Gaps in the timeline for this room. More... | |
PromiseT | paginateBackFromEvent (std::string eventId) const |
Try to paginate back from eventId . More... | |
auto | localEchoes () const -> lager::reader< immer::flex_vector< LocalEchoDesc >> |
Get the list of local echoes in this room. More... | |
PromiseT | removeLocalEcho (std::string txnId) const |
Remove a local echo from this room. More... | |
auto | pendingRoomKeyEvents () const -> lager::reader< immer::flex_vector< PendingRoomKeyEvent >> |
Get the list of pending room key events in this room. More... | |
auto | powerLevels () const -> lager::reader< PowerLevelsDesc > |
Get the power levels of this room. More... | |
auto | relatedEvents (lager::reader< std::string > eventId, std::string relType) const -> lager::reader< EventList > |
Get a list of child events of a specified event. More... | |
auto | eventReaders (lager::reader< std::string > eventId) const -> lager::reader< immer::flex_vector< EventReader >> |
Get a list of read receipts of some event in this room. More... | |
PromiseT | postReceipt (std::string eventId) const |
Post a read receipt for this room. More... | |
auto | unreadNotificationEventIds () const -> lager::reader< immer::flex_vector< std::string >> |
Get a list of event ids of unread notifications. More... | |
Represent a Matrix room.
This class has the same constraints as Client.
using Kazv::Room::ContextT = Context<ClientAction> |
using Kazv::Room::DepsT = lager::deps<SdkModelCursorKey, RandomInterface & > |
Kazv::Room::Room | ( | lager::reader< SdkModel > | sdk, |
lager::reader< std::string > | roomId, | ||
ContextT | ctx | ||
) |
Constructor.
Construct the room with roomId
.
sdk
and roomId
must be cursors in the same thread.
The constructed room will be in the same thread as sdk
and roomId
.
Client::room()
and Client::roomBycursor()
instead. Kazv::Room::Room | ( | lager::reader< SdkModel > | sdk, |
lager::reader< std::string > | roomId, | ||
ContextT | ctx, | ||
DepsT | deps | ||
) |
Constructor.
Construct the room with roomId
and with Deps support.
sdk
and roomId
must be cursors in the same thread.
The constructed room will be in the same thread as sdk
and roomId
.
Client::room()
and Client::roomBycursor()
instead. Kazv::Room::Room | ( | InEventLoopTag | , |
std::string | roomId, | ||
ContextT | ctx, | ||
DepsT | deps | ||
) |
Construct a Room in the same thread as the event loop.
The constructed Room is not constructed from a cursor, and thus copying-constructing from that is thread-safe as long as each thread calls with different objects.
this must have Deps support.
Client::room()
and Client::roomBycursor()
instead.
|
inline |
|
inline |
|
inline |
auto Kazv::Room::addOrSetTag | ( | std::string | tagId, |
std::optional< double > | order = std::nullopt |
||
) | const |
Add or set a tag to this room.
tagId | The tag id to add or set. |
order | The order to specify. |
|
inline |
auto Kazv::Room::avatarMxcUri | ( | ) | const -> lager::reader<std::string> |
Get the avatar mxc uri of this room.
auto Kazv::Room::ban | ( | std::string | userId, |
std::optional< std::string > | reason = std::nullopt |
||
) | const |
Ban a user from this room.
You must have enough power levels in this room to do so.
userId | The id of the user that will be banned. |
reason | The reason to explain this ban. |
auto Kazv::Room::bannedMemberEvents | ( | ) | const -> lager::reader<EventList> |
Get the list of banned member events.
auto Kazv::Room::bannedMembers | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get the list of banned member ids.
lager::reader< bool > Kazv::Room::encrypted | ( | ) | const |
Get whether this room is encrypted.
The encryption status is changed to true if the client receives a state event that turns on encryption. If that state event is removed later, the status will not be changed.
|
inline |
|
inline |
|
inline |
auto Kazv::Room::eventReaders | ( | lager::reader< std::string > | eventId | ) | const -> lager::reader<immer::flex_vector<EventReader>> |
Get a list of read receipts of some event in this room.
eventId | The id of the event. |
auto Kazv::Room::forget | ( | ) | const |
Forget this room.
One can only forget a room when they have already left it.
auto Kazv::Room::getStateEvent | ( | std::string | type, |
std::string | stateKey | ||
) | const |
auto Kazv::Room::heroDisplayNames | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get the member events of heroes this room.
auto Kazv::Room::heroIds | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get the ids of the heroes of the room.
auto Kazv::Room::heroMemberEvents | ( | ) | const -> lager::reader<immer::flex_vector<Event>> |
auto Kazv::Room::invite | ( | std::string | userId | ) | const |
Invite a user to this room.
userId | The user id for the user to invite. |
auto Kazv::Room::invitedMemberCount | ( | ) | const -> lager::reader<std::size_t> |
Get the invited member count of this room.
auto Kazv::Room::invitedMemberEvents | ( | ) | const -> lager::reader<EventList> |
Get the list of invited member events.
auto Kazv::Room::invitedMembers | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get the list of invited member ids.
auto Kazv::Room::inviteState | ( | ) | const -> lager::reader<immer::map<KeyOfState, Event>> |
Get the invite_state of this room.
auto Kazv::Room::joinedMemberCount | ( | ) | const -> lager::reader<std::size_t> |
Get the joined member count of this room.
auto Kazv::Room::joinedMemberEvents | ( | ) | const -> lager::reader<EventList> |
Get the list of joined member events.
Kazv::Room::KAZV_WRAP_ATTR | ( | RoomModel | , |
roomCursor() | , | ||
localDraft | |||
) |
Kazv::Room::KAZV_WRAP_ATTR | ( | RoomModel | , |
roomCursor() | , | ||
membersFullyLoaded | |||
) |
Kazv::Room::KAZV_WRAP_ATTR | ( | RoomModel | , |
roomCursor() | , | ||
membership | |||
) |
Kazv::Room::KAZV_WRAP_ATTR | ( | RoomModel | , |
roomCursor() | , | ||
roomId | |||
) |
auto Kazv::Room::kick | ( | std::string | userId, |
std::optional< std::string > | reason = std::nullopt |
||
) | const |
Kick a user from this room.
You must have enough power levels in this room to do so.
userId | The id of the user that will be kicked. |
reason | The reason to explain this kick. |
auto Kazv::Room::knockedMemberEvents | ( | ) | const -> lager::reader<EventList> |
Get the list of knocked member events.
auto Kazv::Room::knockedMembers | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get the list of knocked member ids.
auto Kazv::Room::leave | ( | ) | const |
Leave this room.
auto Kazv::Room::leftMemberEvents | ( | ) | const -> lager::reader<EventList> |
Get the list of left member events.
auto Kazv::Room::leftMembers | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get the list of left member ids.
auto Kazv::Room::localEcho | ( | lager::reader< std::string > | txnId | ) | const -> lager::reader<LocalEchoDesc> |
Get one local echo by the txnId.
A | lager::reader of the txnId. |
auto Kazv::Room::localEchoes | ( | ) | const -> lager::reader<immer::flex_vector<LocalEchoDesc>> |
Get the list of local echoes in this room.
auto Kazv::Room::localReadMarker | ( | ) | const -> lager::reader<std::string> |
Get the local read marker in this room.
auto Kazv::Room::memberEventByCursor | ( | lager::reader< std::string > | userId | ) | const -> lager::reader<Event> |
Get the member event for userId.
If membership of the current user is Invite, it prefers the event in inviteState to the one in stateEvents.
auto Kazv::Room::memberEventFor | ( | std::string | userId | ) | const -> lager::reader<Event> |
Get the member event for userId.
If membership of the current user is Invite, it prefers the event in inviteState to the one in stateEvents.
auto Kazv::Room::members | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get the list of joined member ids.
auto Kazv::Room::message | ( | lager::reader< std::string > | eventId | ) | const -> lager::reader<Event> |
Get one message by the event id.
A | lager::reader of the event id. |
auto Kazv::Room::messagesMap | ( | ) | const -> lager::reader<immer::map<std::string, Event>> |
Get a map from event ids to events.
It takes constant time for the cursor to be updated.
auto Kazv::Room::name | ( | ) | const -> lager::reader<std::string> |
Get the name of this room.
If there is a m.room.name state event, the name in it is used. If there is none, the returned cursor will hold a placeholder string.
auto Kazv::Room::nameOpt | ( | ) | const -> lager::reader<std::optional<std::string>> |
Get the name of this room.
If there is a m.room.name state event, the name in it is used. If there is none, the returned cursor will hold std::nullopt.
auto Kazv::Room::paginateBackFromEvent | ( | std::string | eventId | ) | const |
Try to paginate back from eventId
.
eventId | An event id that is in the key of +timelineGaps() . |
+timelineGaps()
will no longer contain eventId as key, and timeline()
will contain the events before eventId in the full event chain on the homeserver. If eventId
is not in +timelineGaps()
, it is considered to be failed. auto Kazv::Room::pendingRoomKeyEvents | ( | ) | const -> lager::reader<immer::flex_vector<PendingRoomKeyEvent>> |
Get the list of pending room key events in this room.
auto Kazv::Room::pinEvents | ( | immer::flex_vector< std::string > | eventIds | ) | const |
Add eventIds to the pinned events of this room.
eventIds | The ids of events you want to add to the pinned events. |
auto Kazv::Room::pinnedEvents | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get pinned events of this room.
auto Kazv::Room::postReceipt | ( | std::string | eventId | ) | const |
Post a read receipt for this room.
eventId | The event id the user has read up to. |
auto Kazv::Room::powerLevels | ( | ) | const -> lager::reader<PowerLevelsDesc> |
Get the power levels of this room.
|
inline |
auto Kazv::Room::redactEvent | ( | std::string | eventId, |
std::optional< std::string > | reason | ||
) | const |
Redact an event.
eventId | The event id of the event you want to redact |
reason | The reason of redaction |
auto Kazv::Room::refreshRoomState | ( | ) | const |
Get the full state of this room.
This method will update the Client as needed.
After the returned Promise resolves successfully, stateEvents()
will contain the fetched state.
auto Kazv::Room::relatedEvents | ( | lager::reader< std::string > | eventId, |
std::string | relType | ||
) | const -> lager::reader<EventList> |
Get a list of child events of a specified event.
eventId | The id of the event. |
relType | The type of the relationship. |
relType
. It is sorted in the same order as the timeline. auto Kazv::Room::removeLocalEcho | ( | std::string | txnId | ) | const |
Remove a local echo from this room.
txnId | The transaction id associated with that local echo. |
auto Kazv::Room::removeTag | ( | std::string | tagId | ) | const |
Remove a tag from this room.
tagId | The tag id to remove. |
auto Kazv::Room::resendMessage | ( | std::string | txnId | ) | const |
Resend an event to this room.
txnId | The transaction id of the unsent message |
auto Kazv::Room::sendAllPendingKeyEvents | ( | ) | const |
Send all pending key events in this room.
auto Kazv::Room::sendMessage | ( | Event | msg | ) | const |
Send an event to this room.
msg | The message to send |
auto Kazv::Room::sendPendingKeyEvent | ( | std::string | txnId | ) | const |
Send one pending key event in this room.
txnId | The transaction id of the pending key event |
auto Kazv::Room::sendStateEvent | ( | Event | state | ) | const |
Send a state event to this room.
state | The state event to send. |
auto Kazv::Room::sendTextMessage | ( | std::string | text | ) | const |
Send a text message to this room.
text | The text |
auto Kazv::Room::setAccountData | ( | Event | accountDataEvent | ) | const |
Set the account data for this room.
auto Kazv::Room::setLocalDraft | ( | std::string | localDraft | ) | const |
auto Kazv::Room::setName | ( | std::string | name | ) | const |
Set the room name.
name | The new name for this room. |
auto Kazv::Room::setPinnedEvents | ( | immer::flex_vector< std::string > | eventIds | ) | const |
Set pinned events of this room.
eventIds | The event ids of the new pinned events |
auto Kazv::Room::setTopic | ( | std::string | topic | ) | const |
Set the room topic.
topic | The new topic for this room. |
auto Kazv::Room::setTyping | ( | bool | typing, |
std::optional< int > | timeoutMs | ||
) | const |
Set the typing status of the current user in this room.
typing | Whether the user is now typing. |
timeoutMs | How long this typing status should last, in milliseconds. |
|
inline |
|
inline |
|
inline |
auto Kazv::Room::tags | ( | ) | const -> lager::reader<immer::map<std::string, double>> |
Get the tags of the current room.
auto Kazv::Room::timelineEventIds | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get the timeline event ids of this room in ascending timestamp order.
It takes constant time for the cursor to be updated.
auto Kazv::Room::timelineEvents | ( | ) | const -> lager::reader<immer::flex_vector<Event>> |
Get a list of timeline events in this room.
It takes O(timeline.size()) time for the cursor to be updated.
auto Kazv::Room::timelineGaps | ( | ) | const |
Get the Gaps in the timeline for this room.
Any key of the map in the returned reader can be send as an argument of paginateBackFromEvent() to try to fill the Gap at that event.
Room Kazv::Room::toEventLoop | ( | ) | const |
Return a Room that represents the room currently represented by this, but suitable for use in the event loop of the context.
This function can only be called from the thread where this belongs.
Example:
|
inline |
auto Kazv::Room::typingMemberEvents | ( | ) | const -> lager::reader<EventList> |
Get the member events of all typing users in this room.
auto Kazv::Room::typingUsers | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get the ids of all typing users in this room.
auto Kazv::Room::unban | ( | std::string | userId | ) | const |
Unban a user from this room.
You must have enough power levels in this room to do so.
userId | The id of the user that will be unbanned. |
auto Kazv::Room::unpinEvents | ( | immer::flex_vector< std::string > | eventIds | ) | const |
Remove eventIds from the pinned events of this room.
eventIds | The ids of events you want to remove from the pinned events. |
auto Kazv::Room::unreadNotificationEventIds | ( | ) | const -> lager::reader<immer::flex_vector<std::string>> |
Get a list of event ids of unread notifications.