libQuotient
A Qt library for building matrix clients
relations.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 Get the child events for a given parent event.
11 //!
12 //! Retrieve all of the child events for a given parent event.
13 //!
14 //! Note that when paginating the `from` token should be "after" the `to` token in
15 //! terms of topological ordering, because it is only possible to paginate "backwards"
16 //! through events, starting at `from`.
17 //!
18 //! For example, passing a `from` token from page 2 of the results, and a `to` token
19 //! from page 1, would return the empty set. The caller can use a `from` token from
20 //! page 1 and a `to` token from page 2 to paginate over the same range, however.
21 class QUOTIENT_API GetRelatingEventsJob : public BaseJob {
22 public:
23  //! \param roomId
24  //! The ID of the room containing the parent event.
25  //!
26  //! \param eventId
27  //! The ID of the parent event whose child events are to be returned.
28  //!
29  //! \param from
30  //! The pagination token to start returning results from. If not supplied, results
31  //! start at the most recent topological event known to the server.
32  //!
33  //! Can be a `next_batch` or `prev_batch` token from a previous call, or a returned
34  //! `start` token from
35  //! [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages), or a
36  //! `next_batch` token from [`/sync`](/client-server-api/#get_matrixclientv3sync).
37  //!
38  //! \param to
39  //! The pagination token to stop returning results at. If not supplied, results
40  //! continue up to `limit` or until there are no more events.
41  //!
42  //! Like `from`, this can be a previous token from a prior call to this endpoint
43  //! or from `/messages` or `/sync`.
44  //!
45  //! \param limit
46  //! The maximum number of results to return in a single `chunk`. The server can
47  //! and should apply a maximum value to this parameter to avoid large responses.
48  //!
49  //! Similarly, the server should apply a default value when not supplied.
50  //!
51  //! \param dir
52  //! Optional (default `b`) direction to return events from. If this is set to `f`, events
53  //! will be returned in chronological order starting at `from`. If it
54  //! is set to `b`, events will be returned in *reverse* chronological
55  //! order, again starting at `from`.
56  //!
57  //! \param recurse
58  //! Whether to additionally include events which only relate indirectly to the
59  //! given event, i.e. events related to the given event via two or more direct relationships.
60  //!
61  //! If set to `false`, only events which have a direct relation with the given
62  //! event will be included.
63  //!
64  //! If set to `true`, events which have an indirect relation with the given event
65  //! will be included additionally up to a certain depth level. Homeservers SHOULD traverse
66  //! at least 3 levels of relationships. Implementations MAY perform more but MUST be careful
67  //! to not infinitely recurse.
68  //!
69  //! The default value is `false`.
70  explicit GetRelatingEventsJob(const QString& roomId, const QString& eventId,
71  const QString& from = {}, const QString& to = {},
72  std::optional<int> limit = std::nullopt, const QString& dir = {},
73  std::optional<bool> recurse = std::nullopt);
74 
75  //! \brief Construct a URL without creating a full-fledged job object
76  //!
77  //! This function can be used when a URL for GetRelatingEventsJob
78  //! is necessary but the job itself isn't.
79  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId,
80  const QString& eventId, const QString& from = {},
81  const QString& to = {}, std::optional<int> limit = std::nullopt,
82  const QString& dir = {}, std::optional<bool> recurse = std::nullopt);
83 
84  // Result properties
85 
86  //! An opaque string representing a pagination token. The absence of this token
87  //! means there are no more results to fetch and the client should stop paginating.
88  QString nextBatch() const { return loadFromJson<QString>("next_batch"_L1); }
89 
90  //! An opaque string representing a pagination token. The absence of this token
91  //! means this is the start of the result set, i.e. this is the first batch/page.
92  QString prevBatch() const { return loadFromJson<QString>("prev_batch"_L1); }
93 
94  //! If the `recurse` parameter was supplied by the client, this response field is
95  //! mandatory and gives the actual depth to which the server recursed. If the client
96  //! did not specify the `recurse` parameter, this field must be absent.
97  std::optional<int> recursionDepth() const
98  {
99  return loadFromJson<std::optional<int>>("recursion_depth"_L1);
100  }
101 
102  //! The child events of the requested event, ordered topologically most-recent first.
103  RoomEvents chunk() { return takeFromJson<RoomEvents>("chunk"_L1); }
104 
105  struct Response {
106  //! An opaque string representing a pagination token. The absence of this token
107  //! means there are no more results to fetch and the client should stop paginating.
108  QString nextBatch{};
109 
110  //! An opaque string representing a pagination token. The absence of this token
111  //! means this is the start of the result set, i.e. this is the first batch/page.
112  QString prevBatch{};
113 
114  //! If the `recurse` parameter was supplied by the client, this response field is
115  //! mandatory and gives the actual depth to which the server recursed. If the client
116  //! did not specify the `recurse` parameter, this field must be absent.
117  std::optional<int> recursionDepth{};
118 
119  //! The child events of the requested event, ordered topologically most-recent first.
120  RoomEvents chunk{};
121  };
122 };
123 
124 template <std::derived_from<GetRelatingEventsJob> JobT>
125 constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> GetRelatingEventsJob::Response {
126  return { j->nextBatch(), j->prevBatch(), j->recursionDepth(), j->chunk() };
127 };
128 
129 //! \brief Get the child events for a given parent event, with a given `relType`.
130 //!
131 //! Retrieve all of the child events for a given parent event which relate to the parent
132 //! using the given `relType`.
133 //!
134 //! Note that when paginating the `from` token should be "after" the `to` token in
135 //! terms of topological ordering, because it is only possible to paginate "backwards"
136 //! through events, starting at `from`.
137 //!
138 //! For example, passing a `from` token from page 2 of the results, and a `to` token
139 //! from page 1, would return the empty set. The caller can use a `from` token from
140 //! page 1 and a `to` token from page 2 to paginate over the same range, however.
141 class QUOTIENT_API GetRelatingEventsWithRelTypeJob : public BaseJob {
142 public:
143  //! \param roomId
144  //! The ID of the room containing the parent event.
145  //!
146  //! \param eventId
147  //! The ID of the parent event whose child events are to be returned.
148  //!
149  //! \param relType
150  //! The [relationship type](/client-server-api/#relationship-types) to search for.
151  //!
152  //! \param from
153  //! The pagination token to start returning results from. If not supplied, results
154  //! start at the most recent topological event known to the server.
155  //!
156  //! Can be a `next_batch` or `prev_batch` token from a previous call, or a returned
157  //! `start` token from
158  //! [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages), or a
159  //! `next_batch` token from [`/sync`](/client-server-api/#get_matrixclientv3sync).
160  //!
161  //! \param to
162  //! The pagination token to stop returning results at. If not supplied, results
163  //! continue up to `limit` or until there are no more events.
164  //!
165  //! Like `from`, this can be a previous token from a prior call to this endpoint
166  //! or from `/messages` or `/sync`.
167  //!
168  //! \param limit
169  //! The maximum number of results to return in a single `chunk`. The server can
170  //! and should apply a maximum value to this parameter to avoid large responses.
171  //!
172  //! Similarly, the server should apply a default value when not supplied.
173  //!
174  //! \param dir
175  //! Optional (default `b`) direction to return events from. If this is set to `f`, events
176  //! will be returned in chronological order starting at `from`. If it
177  //! is set to `b`, events will be returned in *reverse* chronological
178  //! order, again starting at `from`.
179  //!
180  //! \param recurse
181  //! Whether to additionally include events which only relate indirectly to the
182  //! given event, i.e. events related to the given event via two or more direct relationships.
183  //!
184  //! If set to `false`, only events which have a direct relation with the given
185  //! event will be included.
186  //!
187  //! If set to `true`, events which have an indirect relation with the given event
188  //! will be included additionally up to a certain depth level. Homeservers SHOULD traverse
189  //! at least 3 levels of relationships. Implementations MAY perform more but MUST be careful
190  //! to not infinitely recurse.
191  //!
192  //! The default value is `false`.
193  explicit GetRelatingEventsWithRelTypeJob(const QString& roomId, const QString& eventId,
194  const QString& relType, const QString& from = {},
195  const QString& to = {},
196  std::optional<int> limit = std::nullopt,
197  const QString& dir = {},
198  std::optional<bool> recurse = std::nullopt);
199 
200  //! \brief Construct a URL without creating a full-fledged job object
201  //!
202  //! This function can be used when a URL for GetRelatingEventsWithRelTypeJob
203  //! is necessary but the job itself isn't.
204  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId,
205  const QString& eventId, const QString& relType,
206  const QString& from = {}, const QString& to = {},
207  std::optional<int> limit = std::nullopt, const QString& dir = {},
208  std::optional<bool> recurse = std::nullopt);
209 
210  // Result properties
211 
212  //! An opaque string representing a pagination token. The absence of this token
213  //! means there are no more results to fetch and the client should stop paginating.
214  QString nextBatch() const { return loadFromJson<QString>("next_batch"_L1); }
215 
216  //! An opaque string representing a pagination token. The absence of this token
217  //! means this is the start of the result set, i.e. this is the first batch/page.
218  QString prevBatch() const { return loadFromJson<QString>("prev_batch"_L1); }
219 
220  //! If the `recurse` parameter was supplied by the client, this response field is
221  //! mandatory and gives the actual depth to which the server recursed. If the client
222  //! did not specify the `recurse` parameter, this field must be absent.
223  std::optional<int> recursionDepth() const
224  {
225  return loadFromJson<std::optional<int>>("recursion_depth"_L1);
226  }
227 
228  //! The child events of the requested event, ordered topologically
229  //! most-recent first. The events returned will match the `relType`
230  //! supplied in the URL.
231  RoomEvents chunk() { return takeFromJson<RoomEvents>("chunk"_L1); }
232 
233  struct Response {
234  //! An opaque string representing a pagination token. The absence of this token
235  //! means there are no more results to fetch and the client should stop paginating.
236  QString nextBatch{};
237 
238  //! An opaque string representing a pagination token. The absence of this token
239  //! means this is the start of the result set, i.e. this is the first batch/page.
240  QString prevBatch{};
241 
242  //! If the `recurse` parameter was supplied by the client, this response field is
243  //! mandatory and gives the actual depth to which the server recursed. If the client
244  //! did not specify the `recurse` parameter, this field must be absent.
245  std::optional<int> recursionDepth{};
246 
247  //! The child events of the requested event, ordered topologically
248  //! most-recent first. The events returned will match the `relType`
249  //! supplied in the URL.
250  RoomEvents chunk{};
251  };
252 };
253 
254 template <std::derived_from<GetRelatingEventsWithRelTypeJob> JobT>
255 constexpr inline auto doCollectResponse<JobT> =
256  [](JobT* j) -> GetRelatingEventsWithRelTypeJob::Response {
257  return { j->nextBatch(), j->prevBatch(), j->recursionDepth(), j->chunk() };
258 };
259 
260 //! \brief Get the child events for a given parent event, with a given `relType` and `eventType`.
261 //!
262 //! Retrieve all of the child events for a given parent event which relate to the parent
263 //! using the given `relType` and have the given `eventType`.
264 //!
265 //! Note that when paginating the `from` token should be "after" the `to` token in
266 //! terms of topological ordering, because it is only possible to paginate "backwards"
267 //! through events, starting at `from`.
268 //!
269 //! For example, passing a `from` token from page 2 of the results, and a `to` token
270 //! from page 1, would return the empty set. The caller can use a `from` token from
271 //! page 1 and a `to` token from page 2 to paginate over the same range, however.
272 class QUOTIENT_API GetRelatingEventsWithRelTypeAndEventTypeJob : public BaseJob {
273 public:
274  //! \param roomId
275  //! The ID of the room containing the parent event.
276  //!
277  //! \param eventId
278  //! The ID of the parent event whose child events are to be returned.
279  //!
280  //! \param relType
281  //! The [relationship type](/client-server-api/#relationship-types) to search for.
282  //!
283  //! \param eventType
284  //! The event type of child events to search for.
285  //!
286  //! Note that in encrypted rooms this will typically always be `m.room.encrypted`
287  //! regardless of the event type contained within the encrypted payload.
288  //!
289  //! \param from
290  //! The pagination token to start returning results from. If not supplied, results
291  //! start at the most recent topological event known to the server.
292  //!
293  //! Can be a `next_batch` or `prev_batch` token from a previous call, or a returned
294  //! `start` token from
295  //! [`/messages`](/client-server-api/#get_matrixclientv3roomsroomidmessages), or a
296  //! `next_batch` token from [`/sync`](/client-server-api/#get_matrixclientv3sync).
297  //!
298  //! \param to
299  //! The pagination token to stop returning results at. If not supplied, results
300  //! continue up to `limit` or until there are no more events.
301  //!
302  //! Like `from`, this can be a previous token from a prior call to this endpoint
303  //! or from `/messages` or `/sync`.
304  //!
305  //! \param limit
306  //! The maximum number of results to return in a single `chunk`. The server can
307  //! and should apply a maximum value to this parameter to avoid large responses.
308  //!
309  //! Similarly, the server should apply a default value when not supplied.
310  //!
311  //! \param dir
312  //! Optional (default `b`) direction to return events from. If this is set to `f`, events
313  //! will be returned in chronological order starting at `from`. If it
314  //! is set to `b`, events will be returned in *reverse* chronological
315  //! order, again starting at `from`.
316  //!
317  //! \param recurse
318  //! Whether to additionally include events which only relate indirectly to the
319  //! given event, i.e. events related to the given event via two or more direct relationships.
320  //!
321  //! If set to `false`, only events which have a direct relation with the given
322  //! event will be included.
323  //!
324  //! If set to `true`, events which have an indirect relation with the given event
325  //! will be included additionally up to a certain depth level. Homeservers SHOULD traverse
326  //! at least 3 levels of relationships. Implementations MAY perform more but MUST be careful
327  //! to not infinitely recurse.
328  //!
329  //! The default value is `false`.
330  explicit GetRelatingEventsWithRelTypeAndEventTypeJob(
331  const QString& roomId, const QString& eventId, const QString& relType,
332  const QString& eventType, const QString& from = {}, const QString& to = {},
333  std::optional<int> limit = std::nullopt, const QString& dir = {},
334  std::optional<bool> recurse = std::nullopt);
335 
336  //! \brief Construct a URL without creating a full-fledged job object
337  //!
338  //! This function can be used when a URL for GetRelatingEventsWithRelTypeAndEventTypeJob
339  //! is necessary but the job itself isn't.
340  static QUrl makeRequestUrl(const HomeserverData& hsData, const QString& roomId,
341  const QString& eventId, const QString& relType,
342  const QString& eventType, const QString& from = {},
343  const QString& to = {}, std::optional<int> limit = std::nullopt,
344  const QString& dir = {}, std::optional<bool> recurse = std::nullopt);
345 
346  // Result properties
347 
348  //! An opaque string representing a pagination token. The absence of this token
349  //! means there are no more results to fetch and the client should stop paginating.
350  QString nextBatch() const { return loadFromJson<QString>("next_batch"_L1); }
351 
352  //! An opaque string representing a pagination token. The absence of this token
353  //! means this is the start of the result set, i.e. this is the first batch/page.
354  QString prevBatch() const { return loadFromJson<QString>("prev_batch"_L1); }
355 
356  //! If the `recurse` parameter was supplied by the client, this response field is
357  //! mandatory and gives the actual depth to which the server recursed. If the client
358  //! did not specify the `recurse` parameter, this field must be absent.
359  std::optional<int> recursionDepth() const
360  {
361  return loadFromJson<std::optional<int>>("recursion_depth"_L1);
362  }
363 
364  //! The child events of the requested event, ordered topologically most-recent
365  //! first. The events returned will match the `relType` and `eventType` supplied
366  //! in the URL.
367  RoomEvents chunk() { return takeFromJson<RoomEvents>("chunk"_L1); }
368 
369  struct Response {
370  //! An opaque string representing a pagination token. The absence of this token
371  //! means there are no more results to fetch and the client should stop paginating.
372  QString nextBatch{};
373 
374  //! An opaque string representing a pagination token. The absence of this token
375  //! means this is the start of the result set, i.e. this is the first batch/page.
376  QString prevBatch{};
377 
378  //! If the `recurse` parameter was supplied by the client, this response field is
379  //! mandatory and gives the actual depth to which the server recursed. If the client
380  //! did not specify the `recurse` parameter, this field must be absent.
381  std::optional<int> recursionDepth{};
382 
383  //! The child events of the requested event, ordered topologically most-recent
384  //! first. The events returned will match the `relType` and `eventType` supplied
385  //! in the URL.
386  RoomEvents chunk{};
387  };
388 };
389 
390 template <std::derived_from<GetRelatingEventsWithRelTypeAndEventTypeJob> JobT>
391 constexpr inline auto doCollectResponse<JobT> =
392  [](JobT* j) -> GetRelatingEventsWithRelTypeAndEventTypeJob::Response {
393  return { j->nextBatch(), j->prevBatch(), j->recursionDepth(), j->chunk() };
394 };
395 
396 } // namespace Quotient