diff options
author | Smitty <me@smitop.com> | 2021-11-07 17:08:53 -0500 |
---|---|---|
committer | Smitty <me@smitop.com> | 2021-11-07 17:08:53 -0500 |
commit | 965f0e94f3f8c98ccb704b1d5abdeac1efc699cc (patch) | |
tree | 53af8146affede10b8c422f7b17e6be2a0d36b02 | |
parent | 316069f3c342b64598a40d9d7fd6e015ec0c91dd (diff) | |
download | libquotient-965f0e94f3f8c98ccb704b1d5abdeac1efc699cc.tar.gz libquotient-965f0e94f3f8c98ccb704b1d5abdeac1efc699cc.zip |
Add method to get all state events in a room
It is useful to be able to get all of the state events that have
occured in a room, instead of needing to use Room::getCurrentState,
which filters based on the event type and state key.
-rw-r--r-- | lib/room.cpp | 10 | ||||
-rw-r--r-- | lib/room.h | 6 |
2 files changed, 16 insertions, 0 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index e1d41fc3..3b00d2d9 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -224,6 +224,11 @@ public: return evt; } + const QHash<StateEventKey, const StateEventBase*> stateEvents() const + { + return currentState; + } + template <typename EventT> const EventT* getCurrentState(const QString& stateKey = {}) const { @@ -1293,6 +1298,11 @@ const StateEventBase* Room::getCurrentState(const QString& evtType, return d->getCurrentState({ evtType, stateKey }); } +const QHash<StateEventKey, const StateEventBase*> Room::stateEvents() const +{ + return d->stateEvents(); +} + RoomEventPtr Room::decryptMessage(const EncryptedEvent& encryptedEvent) { #ifndef Quotient_E2EE_ENABLED @@ -508,6 +508,12 @@ public: Q_INVOKABLE const Quotient::StateEventBase* getCurrentState(const QString& evtType, const QString& stateKey = {}) const; + /// Get all state events in the room. + /*! This method returns all known state events that have occured in + * the room, as a mapping from the event type and state key to value. + */ + Q_INVOKABLE const QHash<StateEventKey, const StateEventBase*> stateEvents() const; + /// Get a state event with the given event type and state key /*! This is a typesafe overload that accepts a C++ event type instead of * its Matrix name. |