libQuotient
A Qt library for building matrix clients
filter.h
Go to the documentation of this file.
1 // THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2 
3 #pragma once
4 
5 #include <Quotient/csapi/definitions/sync_filter.h>
6 
7 #include <Quotient/jobs/basejob.h>
8 
9 namespace Quotient {
10 
11 //! \brief Upload a new filter.
12 //!
13 //! Uploads a new filter definition to the homeserver.
14 //! Returns a filter ID that may be used in future requests to
15 //! restrict which events are returned to the client.
16 class QUOTIENT_API DefineFilterJob : public BaseJob {
17 public:
18  //! \param userId
19  //! The id of the user uploading the filter. The access token must be authorized to make
20  //! requests for this user id.
21  //!
22  //! \param filter
23  //! The filter to upload.
24  explicit DefineFilterJob(const QString& userId, const Filter& filter);
25 
26  // Result properties
27 
28  //! The ID of the filter that was created. Cannot start
29  //! with a `{` as this character is used to determine
30  //! if the filter provided is inline JSON or a previously
31  //! declared filter by homeservers on some APIs.
32  QString filterId() const { return loadFromJson<QString>("filter_id"_L1); }
33 };
34 
35 inline auto collectResponse(const DefineFilterJob* job) { return job->filterId(); }
36 
37 //! \brief Download a filter
38 class QUOTIENT_API GetFilterJob : public BaseJob {
39 public:
40  //! \param userId
41  //! The user ID to download a filter for.
42  //!
43  //! \param filterId
44  //! The filter ID to download.
45  explicit GetFilterJob(const QString& userId, const QString& filterId);
46 
47  //! \brief Construct a URL without creating a full-fledged job object
48  //!
49  //! This function can be used when a URL for GetFilterJob
50  //! is necessary but the job itself isn't.
51  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& userId,
52  const QString& filterId);
53 
54  // Result properties
55 
56  //! The filter definition.
57  Filter filter() const { return fromJson<Filter>(jsonData()); }
58 };
59 
60 inline auto collectResponse(const GetFilterJob* job) { return job->filter(); }
61 
62 } // namespace Quotient