aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/list_joined_rooms.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csapi/list_joined_rooms.cpp')
-rw-r--r--lib/csapi/list_joined_rooms.cpp44
1 files changed, 6 insertions, 38 deletions
diff --git a/lib/csapi/list_joined_rooms.cpp b/lib/csapi/list_joined_rooms.cpp
index a745dba1..cdcf3eb2 100644
--- a/lib/csapi/list_joined_rooms.cpp
+++ b/lib/csapi/list_joined_rooms.cpp
@@ -4,49 +4,17 @@
#include "list_joined_rooms.h"
-#include "converters.h"
-
-#include <QtCore/QStringBuilder>
-
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class GetJoinedRoomsJob::Private
-{
- public:
- QStringList joinedRooms;
-};
+using namespace Quotient;
QUrl GetJoinedRoomsJob::makeRequestUrl(QUrl baseUrl)
{
- return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/joined_rooms");
+ return BaseJob::makeRequestUrl(
+ std::move(baseUrl), makePath("/_matrix/client/v3", "/joined_rooms"));
}
-static const auto GetJoinedRoomsJobName = QStringLiteral("GetJoinedRoomsJob");
-
GetJoinedRoomsJob::GetJoinedRoomsJob()
- : BaseJob(HttpVerb::Get, GetJoinedRoomsJobName,
- basePath % "/joined_rooms")
- , d(new Private)
-{
-}
-
-GetJoinedRoomsJob::~GetJoinedRoomsJob() = default;
-
-const QStringList& GetJoinedRoomsJob::joinedRooms() const
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetJoinedRoomsJob"),
+ makePath("/_matrix/client/v3", "/joined_rooms"))
{
- return d->joinedRooms;
+ addExpectedKey("joined_rooms");
}
-
-BaseJob::Status GetJoinedRoomsJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- if (!json.contains("joined_rooms"_ls))
- return { JsonParseError,
- "The key 'joined_rooms' not found in the response" };
- d->joinedRooms = fromJson<QStringList>(json.value("joined_rooms"_ls));
- return Success;
-}
-