aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSmitty <me@smitop.com>2021-11-07 17:08:53 -0500
committerSmitty <me@smitop.com>2021-11-07 17:08:53 -0500
commit965f0e94f3f8c98ccb704b1d5abdeac1efc699cc (patch)
tree53af8146affede10b8c422f7b17e6be2a0d36b02
parent316069f3c342b64598a40d9d7fd6e015ec0c91dd (diff)
downloadlibquotient-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.cpp10
-rw-r--r--lib/room.h6
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
diff --git a/lib/room.h b/lib/room.h
index 55dde2ee..452ea306 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -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.