aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/directory.cpp
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
committerAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
commit09eb39236666e81d5da014acea011dcd74d0999b (patch)
tree52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/directory.cpp
parentf1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff)
parenta4e78956f105875625b572d8b98459ffa86fafe5 (diff)
downloadlibquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz
libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4' with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
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");
}
-