diff options
author | Andres Salomon <dilinger@queued.net> | 2021-01-18 04:00:14 -0500 |
---|---|---|
committer | Andres Salomon <dilinger@queued.net> | 2021-01-18 04:00:14 -0500 |
commit | 09eb39236666e81d5da014acea011dcd74d0999b (patch) | |
tree | 52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/filter.h | |
parent | f1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff) | |
parent | a4e78956f105875625b572d8b98459ffa86fafe5 (diff) | |
download | libquotient-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.h')
-rw-r--r-- | lib/csapi/filter.h | 135 |
1 files changed, 60 insertions, 75 deletions
diff --git a/lib/csapi/filter.h b/lib/csapi/filter.h index 0ca7e953..f07b489c 100644 --- a/lib/csapi/filter.h +++ b/lib/csapi/filter.h @@ -4,82 +4,67 @@ #pragma once -#include "jobs/basejob.h" - -#include "converters.h" #include "csapi/definitions/sync_filter.h" -namespace QMatrixClient -{ - // Operations - - /// Upload a new filter. - /// - /// Uploads a new filter definition to the homeserver. - /// Returns a filter ID that may be used in future requests to - /// restrict which events are returned to the client. - class DefineFilterJob : public BaseJob - { - public: - /*! Upload a new filter. - * \param userId - * The id of the user uploading the filter. The access token must be authorized to make requests for this user id. - * \param filter - * Uploads a new filter definition to the homeserver. - * Returns a filter ID that may be used in future requests to - * restrict which events are returned to the client. - */ - explicit DefineFilterJob(const QString& userId, const Filter& filter); - ~DefineFilterJob() override; - - // Result properties - - /// The ID of the filter that was created. Cannot start - /// with a ``{`` as this character is used to determine - /// if the filter provided is inline JSON or a previously - /// declared filter by homeservers on some APIs. - const QString& filterId() const; - - protected: - Status parseJson(const QJsonDocument& data) override; - - private: - class Private; - QScopedPointer<Private> d; - }; - - /// Download a filter - class GetFilterJob : public BaseJob - { - public: - /*! Download a filter - * \param userId - * The user ID to download a filter for. - * \param filterId - * The filter ID to download. - */ - explicit GetFilterJob(const QString& userId, const QString& filterId); - - /*! Construct a URL without creating a full-fledged job object - * - * This function can be used when a URL for - * GetFilterJob is necessary but the job - * itself isn't. - */ - static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, const QString& filterId); - - ~GetFilterJob() override; - - // Result properties - - /// "The filter defintion" - const Filter& data() const; +#include "jobs/basejob.h" - protected: - Status parseJson(const QJsonDocument& data) override; +namespace Quotient { - private: - class Private; - QScopedPointer<Private> d; - }; -} // namespace QMatrixClient +/*! \brief Upload a new filter. + * + * Uploads a new filter definition to the homeserver. + * Returns a filter ID that may be used in future requests to + * restrict which events are returned to the client. + */ +class DefineFilterJob : public BaseJob { +public: + /*! \brief Upload a new filter. + * + * \param userId + * The id of the user uploading the filter. The access token must be + * authorized to make requests for this user id. + * + * \param filter + * The filter to upload. + */ + explicit DefineFilterJob(const QString& userId, const Filter& filter); + + // Result properties + + /// The ID of the filter that was created. Cannot start + /// with a ``{`` as this character is used to determine + /// if the filter provided is inline JSON or a previously + /// declared filter by homeservers on some APIs. + QString filterId() const { return loadFromJson<QString>("filter_id"_ls); } +}; + +/*! \brief Download a filter + * + */ +class GetFilterJob : public BaseJob { +public: + /*! \brief Download a filter + * + * \param userId + * The user ID to download a filter for. + * + * \param filterId + * The filter ID to download. + */ + explicit GetFilterJob(const QString& userId, const QString& filterId); + + /*! \brief Construct a URL without creating a full-fledged job object + * + * This function can be used when a URL for GetFilterJob + * is necessary but the job itself isn't. + */ + static QUrl makeRequestUrl(QUrl baseUrl, const QString& userId, + const QString& filterId); + + // Result properties + + /// The filter definition. + Filter filter() const { return fromJson<Filter>(jsonData()); } +}; + +} // namespace Quotient |