aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-09 19:26:19 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-09 21:16:01 +0900
commit0ec97b031c4d89acc9ea6e343620f3762f8eb51b (patch)
tree59461be6c61590b836b3b549648f1a1535c14578 /lib/csapi
parentd1cf4bc530613a9d3ee10768dd068a0391f6e105 (diff)
downloadlibquotient-0ec97b031c4d89acc9ea6e343620f3762f8eb51b.tar.gz
libquotient-0ec97b031c4d89acc9ea6e343620f3762f8eb51b.zip
csapi: UpgradeRoomJob (MSC1501)
Diffstat (limited to 'lib/csapi')
-rw-r--r--lib/csapi/room_upgrades.cpp49
-rw-r--r--lib/csapi/room_upgrades.h43
2 files changed, 92 insertions, 0 deletions
diff --git a/lib/csapi/room_upgrades.cpp b/lib/csapi/room_upgrades.cpp
new file mode 100644
index 00000000..f58fd675
--- /dev/null
+++ b/lib/csapi/room_upgrades.cpp
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#include "room_upgrades.h"
+
+#include "converters.h"
+
+#include <QtCore/QStringBuilder>
+
+using namespace QMatrixClient;
+
+static const auto basePath = QStringLiteral("/_matrix/client/r0");
+
+class UpgradeRoomJob::Private
+{
+ public:
+ QString replacementRoom;
+};
+
+static const auto UpgradeRoomJobName = QStringLiteral("UpgradeRoomJob");
+
+UpgradeRoomJob::UpgradeRoomJob(const QString& roomId, const QString& newVersion)
+ : BaseJob(HttpVerb::Post, UpgradeRoomJobName,
+ basePath % "/rooms/" % roomId % "/upgrade")
+ , d(new Private)
+{
+ QJsonObject _data;
+ addParam<>(_data, QStringLiteral("new_version"), newVersion);
+ setRequestData(_data);
+}
+
+UpgradeRoomJob::~UpgradeRoomJob() = default;
+
+const QString& UpgradeRoomJob::replacementRoom() const
+{
+ return d->replacementRoom;
+}
+
+BaseJob::Status UpgradeRoomJob::parseJson(const QJsonDocument& data)
+{
+ auto json = data.object();
+ if (!json.contains("replacement_room"_ls))
+ return { JsonParseError,
+ "The key 'replacement_room' not found in the response" };
+ fromJson(json.value("replacement_room"_ls), d->replacementRoom);
+ return Success;
+}
+
diff --git a/lib/csapi/room_upgrades.h b/lib/csapi/room_upgrades.h
new file mode 100644
index 00000000..6f712f10
--- /dev/null
+++ b/lib/csapi/room_upgrades.h
@@ -0,0 +1,43 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#pragma once
+
+#include "jobs/basejob.h"
+
+
+namespace QMatrixClient
+{
+ // Operations
+
+ /// Upgrades a room to a new room version.
+ ///
+ /// Upgrades the given room to a particular room version, migrating as much
+ /// data as possible over to the new room. See the `room_upgrades <#room-upgrades>`_
+ /// module for more information on what this entails.
+ class UpgradeRoomJob : public BaseJob
+ {
+ public:
+ /*! Upgrades a room to a new room version.
+ * \param roomId
+ * The ID of the room to upgrade.
+ * \param newVersion
+ * The new version for the room.
+ */
+ explicit UpgradeRoomJob(const QString& roomId, const QString& newVersion);
+ ~UpgradeRoomJob() override;
+
+ // Result properties
+
+ /// The ID of the new room.
+ const QString& replacementRoom() const;
+
+ protected:
+ Status parseJson(const QJsonDocument& data) override;
+
+ private:
+ class Private;
+ QScopedPointer<Private> d;
+ };
+} // namespace QMatrixClient