aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/filter.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/filter.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/filter.cpp')
-rw-r--r--lib/csapi/filter.cpp75
1 files changed, 13 insertions, 62 deletions
diff --git a/lib/csapi/filter.cpp b/lib/csapi/filter.cpp
index 982e60b5..bb3a893f 100644
--- a/lib/csapi/filter.cpp
+++ b/lib/csapi/filter.cpp
@@ -4,78 +4,29 @@
#include "filter.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class DefineFilterJob::Private
-{
- public:
- QString filterId;
-};
-
-static const auto DefineFilterJobName = QStringLiteral("DefineFilterJob");
+using namespace Quotient;
DefineFilterJob::DefineFilterJob(const QString& userId, const Filter& filter)
- : BaseJob(HttpVerb::Post, DefineFilterJobName,
- basePath % "/user/" % userId % "/filter")
- , d(new Private)
+ : BaseJob(HttpVerb::Post, QStringLiteral("DefineFilterJob"),
+ QStringLiteral("/_matrix/client/r0") % "/user/" % userId
+ % "/filter")
{
setRequestData(Data(toJson(filter)));
+ addExpectedKey("filter_id");
}
-DefineFilterJob::~DefineFilterJob() = default;
-
-const QString& DefineFilterJob::filterId() const
-{
- return d->filterId;
-}
-
-BaseJob::Status DefineFilterJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- if (!json.contains("filter_id"_ls))
- return { JsonParseError,
- "The key 'filter_id' not found in the response" };
- fromJson(json.value("filter_id"_ls), d->filterId);
- return Success;
-}
-
-class GetFilterJob::Private
-{
- public:
- Filter data;
-};
-
-QUrl GetFilterJob::makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId)
+QUrl GetFilterJob::makeRequestUrl(QUrl baseUrl, const QString& userId,
+ const QString& filterId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/user/" % userId % "/filter/" % filterId);
+ QStringLiteral("/_matrix/client/r0") % "/user/"
+ % userId % "/filter/" % filterId);
}
-static const auto GetFilterJobName = QStringLiteral("GetFilterJob");
-
GetFilterJob::GetFilterJob(const QString& userId, const QString& filterId)
- : BaseJob(HttpVerb::Get, GetFilterJobName,
- basePath % "/user/" % userId % "/filter/" % filterId)
- , d(new Private)
-{
-}
-
-GetFilterJob::~GetFilterJob() = default;
-
-const Filter& GetFilterJob::data() const
-{
- return d->data;
-}
-
-BaseJob::Status GetFilterJob::parseJson(const QJsonDocument& data)
-{
- fromJson(data, d->data);
- return Success;
-}
-
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetFilterJob"),
+ QStringLiteral("/_matrix/client/r0") % "/user/" % userId
+ % "/filter/" % filterId)
+{}