aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/directory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csapi/directory.cpp')
-rw-r--r--lib/csapi/directory.cpp78
1 files changed, 29 insertions, 49 deletions
diff --git a/lib/csapi/directory.cpp b/lib/csapi/directory.cpp
index 4af86f7b..25ea82e2 100644
--- a/lib/csapi/directory.cpp
+++ b/lib/csapi/directory.cpp
@@ -4,78 +4,58 @@
#include "directory.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0/directory");
-
-static const auto SetRoomAliasJobName = QStringLiteral("SetRoomAliasJob");
+using namespace Quotient;
SetRoomAliasJob::SetRoomAliasJob(const QString& roomAlias, const QString& roomId)
- : BaseJob(HttpVerb::Put, SetRoomAliasJobName,
- basePath % "/room/" % roomAlias)
+ : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomAliasJob"),
+ QStringLiteral("/_matrix/client/r0") % "/directory/room/"
+ % roomAlias)
{
QJsonObject _data;
addParam<>(_data, QStringLiteral("room_id"), roomId);
- setRequestData(_data);
+ setRequestData(std::move(_data));
}
-class GetRoomIdByAliasJob::Private
-{
- public:
- QString roomId;
- QStringList servers;
-};
-
QUrl GetRoomIdByAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/room/" % roomAlias);
+ QStringLiteral("/_matrix/client/r0")
+ % "/directory/room/" % roomAlias);
}
-static const auto GetRoomIdByAliasJobName = QStringLiteral("GetRoomIdByAliasJob");
-
GetRoomIdByAliasJob::GetRoomIdByAliasJob(const QString& roomAlias)
- : BaseJob(HttpVerb::Get, GetRoomIdByAliasJobName,
- basePath % "/room/" % roomAlias, false)
- , d(new Private)
-{
-}
-
-GetRoomIdByAliasJob::~GetRoomIdByAliasJob() = default;
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomIdByAliasJob"),
+ QStringLiteral("/_matrix/client/r0") % "/directory/room/"
+ % roomAlias,
+ false)
+{}
-const QString& GetRoomIdByAliasJob::roomId() const
-{
- return d->roomId;
-}
-
-const QStringList& GetRoomIdByAliasJob::servers() const
+QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias)
{
- return d->servers;
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ QStringLiteral("/_matrix/client/r0")
+ % "/directory/room/" % roomAlias);
}
-BaseJob::Status GetRoomIdByAliasJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- fromJson(json.value("room_id"_ls), d->roomId);
- fromJson(json.value("servers"_ls), d->servers);
- return Success;
-}
+DeleteRoomAliasJob::DeleteRoomAliasJob(const QString& roomAlias)
+ : BaseJob(HttpVerb::Delete, QStringLiteral("DeleteRoomAliasJob"),
+ QStringLiteral("/_matrix/client/r0") % "/directory/room/"
+ % roomAlias)
+{}
-QUrl DeleteRoomAliasJob::makeRequestUrl(QUrl baseUrl, const QString& roomAlias)
+QUrl GetLocalAliasesJob::makeRequestUrl(QUrl baseUrl, const QString& roomId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/room/" % roomAlias);
+ QStringLiteral("/_matrix/client/r0")
+ % "/rooms/" % roomId % "/aliases");
}
-static const auto DeleteRoomAliasJobName = QStringLiteral("DeleteRoomAliasJob");
-
-DeleteRoomAliasJob::DeleteRoomAliasJob(const QString& roomAlias)
- : BaseJob(HttpVerb::Delete, DeleteRoomAliasJobName,
- basePath % "/room/" % roomAlias)
+GetLocalAliasesJob::GetLocalAliasesJob(const QString& roomId)
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetLocalAliasesJob"),
+ QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId
+ % "/aliases")
{
+ addExpectedKey("aliases");
}
-