Go to the documentation of this file.
10 #include <lager/reader.hpp>
11 #include <lager/context.hpp>
12 #include <lager/with.hpp>
13 #include <lager/constant.hpp>
14 #include <lager/lenses/optional.hpp>
15 #include <zug/transducer/map.hpp>
16 #include <zug/transducer/filter.hpp>
17 #include <zug/sequence.hpp>
18 #include <immer/flex_vector_transient.hpp>
42 #ifdef KAZV_USE_THREAD_SAFETY_HELPER
43 , EventLoopThreadIdKeeper &
62 Room(lager::reader<SdkModel> sdk,
63 lager::reader<std::string> roomId,
78 Room(lager::reader<SdkModel> sdk,
79 lager::reader<std::string> roomId,
144 [lager::lenses::or_default];
179 auto
message(lager::reader<
std::
string> eventId) const -> lager::reader<
Event>;
212 auto
nameOpt() const -> lager::reader<
std::optional<
std::
string>>;
222 auto
name() const -> lager::reader<
std::
string>;
236 auto
members() const -> lager::reader<immer::flex_vector<
std::
string>>;
257 auto
leftMembers() const -> lager::reader<immer::flex_vector<
std::
string>>;
264 auto
bannedMembers() const -> lager::reader<immer::flex_vector<
std::
string>>;
349 auto
heroIds() const -> lager::reader<immer::flex_vector<
std::
string>>;
480 using namespace lager::lenses;
524 [lager::lenses::or_default];
532 auto typingUsers() const -> lager::reader<immer::flex_vector<
std::
string>>;
570 [lager::lenses::or_default];
575 using namespace lager::lenses;
578 |
jsonAtOr(
"event_id", std::string{}));
595 auto tags() const -> lager::reader<immer::map<
std::
string,
double>>;
686 auto pinnedEvents() const -> lager::reader<immer::flex_vector<
std::
string>>;
809 const lager::reader<
SdkModel> &sdkCursor() const;
810 const lager::reader<
RoomModel> &roomCursor() const;
811 lager::reader<
RoomModel> makeRoomCursor() const;
812 std::
string currentRoomId() const;
814 lager::reader<immer::map<
KeyOfState,
Event>> inviteStateOrState() const;
816 lager::reader<
Event> inviteStateOrStateEvent(lager::reader<
KeyOfState> key) const;
819 std::variant<lager::reader<
std::
string>,
std::
string> m_roomId;
824 KAZV_DECLARE_THREAD_ID();
825 KAZV_DECLARE_EVENT_LOOP_THREAD_ID_KEEPER(m_deps.has_value() ? &lager::get<EventLoopThreadIdKeeper &>(m_deps.value()) : 0);
PromiseT refreshRoomState() const
Get the full state of this room.
Definition: room.cpp:630
auto powerLevels() const -> lager::reader< PowerLevelsDesc >
Get the power levels of this room.
Definition: room.cpp:885
PromiseT leave() const
Leave this room.
Definition: room.cpp:711
Represent a m.power_levels event.
Definition: power-levels-desc.hpp:25
PromiseT postReceipt(std::string eventId) const
Post a read receipt for this room.
Definition: room.cpp:932
auto invitedMembers() const -> lager::reader< immer::flex_vector< std::string >>
Get the list of invited member ids.
Definition: room.cpp:128
auto knockedMembers() const -> lager::reader< immer::flex_vector< std::string >>
Get the list of knocked member ids.
Definition: room.cpp:135
PromiseT setName(std::string name) const
Set the room name.
Definition: room.cpp:651
immer::map< KeyOfState, Event > stateEvents
Definition: room-model.hpp:217
Room(lager::reader< SdkModel > sdk, lager::reader< std::string > roomId, ContextT ctx)
Constructor.
PromiseT setAccountData(Event accountDataEvent) const
Set the account data for this room.
Definition: room.cpp:746
Definition: room-model.hpp:31
PromiseT resendMessage(std::string txnId) const
Resend an event to this room.
Definition: room.cpp:531
PromiseT addOrSetTag(std::string tagId, std::optional< double > order=std::nullopt) const
Add or set a tag to this room.
Definition: room.cpp:757
Definition: context.hpp:129
auto members() const -> lager::reader< immer::flex_vector< std::string >>
Get the list of joined member ids.
Definition: room.cpp:121
PromiseT ban(std::string userId, std::optional< std::string > reason=std::nullopt) const
Ban a user from this room.
Definition: room.cpp:732
auto invitedMemberEvents() const -> lager::reader< EventList >
Get the list of invited member events.
Definition: room.cpp:163
auto heroIds() const -> lager::reader< immer::flex_vector< std::string >>
Get the ids of the heroes of the room.
Definition: room.cpp:281
PromiseT sendTextMessage(std::string text) const
Send a text message to this room.
Definition: room.cpp:516
auto accountDataEvents() const
Definition: room.hpp:553
auto pinnedEvents() const -> lager::reader< immer::flex_vector< std::string >>
Get pinned events of this room.
Definition: room.cpp:775
PromiseT getStateEvent(std::string type, std::string stateKey) const
Get one state event with type and stateKey .
Definition: room.cpp:637
PromiseT removeTag(std::string tagId) const
Remove a tag from this room.
Definition: room.cpp:766
lager::reader< immer::map< std::string, std::string > > timelineGaps() const
Get the Gaps in the timeline for this room.
Definition: room.cpp:852
PromiseT pinEvents(immer::flex_vector< std::string > eventIds) const
Add eventIds to the pinned events of this room.
Definition: room.cpp:795
auto heroDisplayNames() const -> lager::reader< immer::flex_vector< std::string >>
Get the member events of heroes this room.
Definition: room.cpp:239
KAZV_WRAP_ATTR(RoomModel, roomCursor(), roomId)
auto unreadNotificationEventIds() const -> lager::reader< immer::flex_vector< std::string >>
Get a list of event ids of unread notifications.
Definition: room.cpp:937
Definition: location.hpp:10
lager::dep::key< SdkModelCursorTag, lager::dep::fn< std::shared_ptr< lager::reader< SdkModel > >> > SdkModelCursorKey
Definition: sdk-model-cursor-tag.hpp:23
PromiseT setTyping(bool typing, std::optional< int > timeoutMs) const
Set the typing status of the current user in this room.
Definition: room.cpp:704
auto avatarMxcUri() const -> lager::reader< std::string >
Get the avatar mxc uri of this room.
Definition: room.cpp:299
auto nameOpt() const -> lager::reader< std::optional< std::string >>
Get the name of this room.
Definition: room.cpp:256
auto timelineEvents() const -> lager::reader< immer::flex_vector< Event >>
Get a list of timeline events in this room.
Definition: room.cpp:837
SingleTypePromise< DefaultRetType > PromiseT
Definition: room.hpp:40
auto state(KeyOfState k) const
Definition: room.hpp:142
auto ephemeral(std::string type) const
Definition: room.hpp:520
Definition: random-generator.hpp:15
constexpr auto jsonAtOr(T &&key, V &&defaultValue)
Definition: cursorutil.hpp:140
PromiseT kick(std::string userId, std::optional< std::string > reason=std::nullopt) const
Kick a user from this room.
Definition: room.cpp:725
Room toEventLoop() const
Return a Room that represents the room currently represented by this, but suitable for use in the eve...
Definition: room.cpp:52
Definition: room-model.hpp:209
auto localEcho(lager::reader< std::string > txnId) const -> lager::reader< LocalEchoDesc >
Get one local echo by the txnId.
Definition: room.cpp:105
immer::map< std::string, Event > ephemeral
Definition: room-model.hpp:231
Definition: room-model.hpp:54
PromiseT forget() const
Forget this room.
Definition: room.cpp:718
auto bannedMembers() const -> lager::reader< immer::flex_vector< std::string >>
Get the list of banned member ids.
Definition: room.cpp:149
auto stateEvents() const
Definition: room.hpp:123
auto joinedMemberCount() const -> lager::reader< std::size_t >
Get the joined member count of this room.
Definition: room.cpp:289
PromiseT sendAllPendingKeyEvents() const
Send all pending key events in this room.
Definition: room.cpp:609
auto heroMemberEvents() const -> lager::reader< immer::flex_vector< Event >>
Get the member events of heroes this room.
Definition: room.cpp:233
PromiseT invite(std::string userId) const
Invite a user to this room.
Definition: room.cpp:679
auto topic() const
Definition: room.hpp:479
auto accountData(std::string type) const
Definition: room.hpp:566
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.
Definition: room.cpp:914
auto joinedMemberEvents() const -> lager::reader< EventList >
Get the list of joined member events.
Definition: room.cpp:156
constexpr auto eventContent
Definition: cursorutil.hpp:128
PromiseT paginateBackFromEvent(std::string eventId) const
Try to paginate back from eventId.
Definition: room.cpp:859
auto message(lager::reader< std::string > eventId) const -> lager::reader< Event >
Get one message by the event id.
Definition: room.cpp:97
PromiseT setTopic(std::string topic) const
Set the room topic.
Definition: room.cpp:665
auto typingUsers() const -> lager::reader< immer::flex_vector< std::string >>
Get the ids of all typing users in this room.
Definition: room.cpp:686
lager::reader< bool > encrypted() const
Get whether this room is encrypted.
Definition: room.cpp:276
auto bannedMemberEvents() const -> lager::reader< EventList >
Get the list of banned member events.
Definition: room.cpp:184
auto inviteState() const -> lager::reader< immer::map< KeyOfState, Event >>
Get the invite_state of this room.
Definition: room.cpp:228
PromiseT sendStateEvent(Event state) const
Send a state event to this room.
Definition: room.cpp:644
auto ephemeralEvents() const
Definition: room.hpp:507
auto timelineEventIds() const -> lager::reader< immer::flex_vector< std::string >>
Get the timeline event ids of this room in ascending timestamp order.
Definition: room.cpp:827
auto tags() const -> lager::reader< immer::map< std::string, double >>
Get the tags of the current room.
Definition: room.cpp:752
PromiseT removeLocalEcho(std::string txnId) const
Remove a local echo from this room.
Definition: room.cpp:872
auto name() const -> lager::reader< std::string >
Get the name of this room.
Definition: room.cpp:270
auto messagesMap() const -> lager::reader< immer::map< std::string, Event >>
Get a map from event ids to events.
Definition: room.cpp:832
PromiseT sendMessage(Event msg) const
Send an event to this room.
Definition: room.cpp:320
lager::deps< SdkModelCursorKey, RandomInterface & > DepsT
Definition: room.hpp:45
auto memberEventByCursor(lager::reader< std::string > userId) const -> lager::reader< Event >
Get the member event for userId.
Definition: room.cpp:191
auto knockedMemberEvents() const -> lager::reader< EventList >
Get the list of knocked member events.
Definition: room.cpp:170
auto invitedMemberCount() const -> lager::reader< std::size_t >
Get the invited member count of this room.
Definition: room.cpp:294
PromiseT redactEvent(std::string eventId, std::optional< std::string > reason) const
Redact an event.
Definition: room.cpp:571
auto typingMemberEvents() const -> lager::reader< EventList >
Get the member events of all typing users in this room.
Definition: room.cpp:694
auto localEchoes() const -> lager::reader< immer::flex_vector< LocalEchoDesc >>
Get the list of local echoes in this room.
Definition: room.cpp:867
PromiseT setPinnedEvents(immer::flex_vector< std::string > eventIds) const
Set pinned events of this room.
Definition: room.cpp:781
auto readMarker() const
Definition: room.hpp:574
auto ephemeralOpt(std::string type) const
Definition: room.hpp:513
Definition: clientutil.hpp:216
auto accountDataOpt(std::string type) const
Definition: room.hpp:559
Represent a Matrix room.
Definition: room.hpp:37
auto avatar() const
Definition: room.hpp:676
Definition: promise-interface.hpp:121
PromiseT unban(std::string userId) const
Unban a user from this room.
Definition: room.cpp:739
PromiseT setLocalDraft(std::string localDraft) const
Set local draft for this room.
Definition: room.cpp:313
auto relatedEvents(lager::reader< std::string > eventId, std::string relType) const -> lager::reader< EventList >
Get a list of child events of a specified event.
Definition: room.cpp:893
PromiseT sendPendingKeyEvent(std::string txnId) const
Send one pending key event in this room.
Definition: room.cpp:580
PromiseT unpinEvents(immer::flex_vector< std::string > eventIds) const
Remove eventIds from the pinned events of this room.
Definition: room.cpp:811
Context< ClientAction > ContextT
Definition: room.hpp:46
immer::map< std::string, Event > accountData
Definition: room-model.hpp:223
auto stateOpt(KeyOfState k) const
Definition: room.hpp:136
immer::flex_vector< Event > EventList
Definition: types.hpp:107
Definition: clientutil.hpp:56
auto leftMembers() const -> lager::reader< immer::flex_vector< std::string >>
Get the list of left member ids.
Definition: room.cpp:142
auto leftMemberEvents() const -> lager::reader< EventList >
Get the list of left member events.
Definition: room.cpp:177
Definition: sdk-model.hpp:25
auto pendingRoomKeyEvents() const -> lager::reader< immer::flex_vector< PendingRoomKeyEvent >>
Get the list of pending room key events in this room.
Definition: room.cpp:880
auto memberEventFor(std::string userId) const -> lager::reader< Event >
Get the member event for userId.
Definition: room.cpp:198
Describes a local echo.
Definition: local-echo.hpp:18