aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connection.cpp2
-rw-r--r--events/event.h3
-rw-r--r--room.cpp19
3 files changed, 13 insertions, 11 deletions
diff --git a/connection.cpp b/connection.cpp
index d15067dd..37d216d7 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -402,7 +402,7 @@ QByteArray Connection::generateTxnId()
return d->data->generateTxnId();
}
-static constexpr int CACHE_VERSION_MAJOR = 0;
+static constexpr int CACHE_VERSION_MAJOR = 1;
static constexpr int CACHE_VERSION_MINOR = 0;
void Connection::saveState(const QUrl &toFile) const
diff --git a/events/event.h b/events/event.h
index 9c915e35..c0c1b603 100644
--- a/events/event.h
+++ b/events/event.h
@@ -159,7 +159,8 @@ namespace QMatrixClient
template <typename... ContentParamTs>
explicit StateEvent(Type type, const QJsonObject& obj,
ContentParamTs&&... contentParams)
- : RoomEvent(type, obj)
+ : RoomEvent(obj.contains("state_key") ? type : Type::Unknown,
+ obj)
, _content(contentJson(),
std::forward<ContentParamTs>(contentParams)...)
{
diff --git a/room.cpp b/room.cpp
index c4e4c6cd..c5c4e721 100644
--- a/room.cpp
+++ b/room.cpp
@@ -973,7 +973,7 @@ void Room::Private::updateDisplayname()
}
template <typename T>
-void appendEventJson(QJsonArray& events, const QString& type,
+void appendStateEvent(QJsonArray& events, const QString& type,
const QString& name, const T& content)
{
if (content.isEmpty())
@@ -985,6 +985,7 @@ void appendEventJson(QJsonArray& events, const QString& type,
QJsonObject eventObj;
eventObj.insert("type", type);
eventObj.insert("content", contentObj);
+ eventObj.insert("state_key", ""); // Mandatory for state events
events.append(eventObj);
}
@@ -995,14 +996,14 @@ QJsonObject Room::Private::toJson() const
{
QJsonArray stateEvents;
- appendEventJson(stateEvents, "m.room.name", "name", name);
- appendEventJson(stateEvents, "m.room.topic", "topic", topic);
- appendEventJson(stateEvents, "m.room.avatar", "url",
- avatar.url().toString());
- appendEventJson(stateEvents, "m.room.aliases", "aliases",
- QJsonArray::fromStringList(aliases));
- appendEventJson(stateEvents, "m.room.canonical_alias", "alias",
- canonicalAlias);
+ appendStateEvent(stateEvents, "m.room.name", "name", name);
+ appendStateEvent(stateEvents, "m.room.topic", "topic", topic);
+ appendStateEvent(stateEvents, "m.room.avatar", "url",
+ avatar.url().toString());
+ appendStateEvent(stateEvents, "m.room.aliases", "aliases",
+ QJsonArray::fromStringList(aliases));
+ appendStateEvent(stateEvents, "m.room.canonical_alias", "alias",
+ canonicalAlias);
for (const auto &i : membersMap)
{