libQuotient
A Qt library for building matrix clients
threads_list.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/events/roomevent.h>
6 #include <Quotient/jobs/basejob.h>
7 
8 namespace Quotient {
9 
10 //! \brief Fetches a list of the threads in a room.
11 //!
12 //! This API is used to paginate through the list of the thread roots in a given room.
13 //!
14 //! Optionally, the returned list may be filtered according to whether the requesting
15 //! user has participated in the thread.
16 class QUOTIENT_API GetThreadRootsJob : public BaseJob {
17 public:
18  //! \param roomId
19  //! The room ID where the thread roots are located.
20  //!
21  //! \param include
22  //! Optional (default `all`) flag to denote which thread roots are of interest to the caller.
23  //! When `all`, all thread roots found in the room are returned. When `participated`, only
24  //! thread roots for threads the user has [participated
25  //! in](/client-server-api/#server-side-aggregation-of-mthread-relationships) will be
26  //! returned.
27  //!
28  //! \param limit
29  //! Optional limit for the maximum number of thread roots to include per response. Must be an
30  //! integer greater than zero.
31  //!
32  //! Servers should apply a default value, and impose a maximum value to avoid resource
33  //! exhaustion.
34  //!
35  //! \param from
36  //! A pagination token from a previous result. When not provided, the server starts paginating
37  //! from the most recent event visible to the user (as per history visibility rules;
38  //! topologically).
39  explicit GetThreadRootsJob(const QString& roomId, const QString& include = {},
40  std::optional<int> limit = std::nullopt, const QString& from = {});
41 
42  //! \brief Construct a URL without creating a full-fledged job object
43  //!
44  //! This function can be used when a URL for GetThreadRootsJob
45  //! is necessary but the job itself isn't.
46  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId,
47  const QString& include = {}, std::optional<int> limit = std::nullopt,
48  const QString& from = {});
49 
50  // Result properties
51 
52  //! The thread roots, ordered by the `latest_event` in each event's aggregated children. All
53  //! events returned include bundled
54  //! [aggregations](/client-server-api/#aggregations-of-child-events).
55  //!
56  //! If the thread root event was sent by an [ignored user](/client-server-api/#ignoring-users),
57  //! the event is returned redacted to the caller. This is to simulate the same behaviour of a
58  //! client doing aggregation locally on the thread.
59  RoomEvents chunk() { return takeFromJson<RoomEvents>("chunk"_L1); }
60 
61  //! A token to supply to `from` to keep paginating the responses. Not present when there are
62  //! no further results.
63  QString nextBatch() const { return loadFromJson<QString>("next_batch"_L1); }
64 
65  struct Response {
66  //! The thread roots, ordered by the `latest_event` in each event's aggregated children. All
67  //! events returned include bundled
68  //! [aggregations](/client-server-api/#aggregations-of-child-events).
69  //!
70  //! If the thread root event was sent by an [ignored
71  //! user](/client-server-api/#ignoring-users), the event is returned redacted to the caller.
72  //! This is to simulate the same behaviour of a client doing aggregation locally on the
73  //! thread.
74  RoomEvents chunk{};
75 
76  //! A token to supply to `from` to keep paginating the responses. Not present when there are
77  //! no further results.
78  QString nextBatch{};
79  };
80 };
81 
82 template <std::derived_from<GetThreadRootsJob> JobT>
83 constexpr inline auto doCollectResponse<JobT> =
84  [](JobT* j) -> GetThreadRootsJob::Response { return { j->chunk(), j->nextBatch() }; };
85 
86 } // namespace Quotient