aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/threads_list.h
blob: 7041583a3bd3775b9947d0b7de1ad5e04c7e8b03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "events/roomevent.h"
#include "jobs/basejob.h"

namespace Quotient {

/*! \brief Retrieve a list of threads in a room, with optional filters.
 *
 * Paginates over the thread roots in a room, ordered by the `latest_event` of
 * each thread root in its bundle.
 */
class QUOTIENT_API GetThreadRootsJob : public BaseJob {
public:
    /*! \brief Retrieve a list of threads in a room, with optional filters.
     *
     * \param roomId
     *   The room ID where the thread roots are located.
     *
     * \param include
     *   Optional (default `all`) flag to denote which thread roots are of
     * interest to the caller. When `all`, all thread roots found in the room
     * are returned. When `participated`, only thread roots for threads the user
     * has [participated
     * in](/client-server-api/#server-side-aggreagtion-of-mthread-relationships)
     *   will be returned.
     *
     * \param limit
     *   Optional limit for the maximum number of thread roots to include per
     * response. Must be an integer greater than zero.
     *
     *   Servers should apply a default value, and impose a maximum value to
     * avoid resource exhaustion.
     *
     * \param from
     *   A pagination token from a previous result. When not provided, the
     * server starts paginating from the most recent event visible to the user
     * (as per history visibility rules; topologically).
     */
    explicit GetThreadRootsJob(const QString& roomId,
                               const QString& include = {},
                               Omittable<int> limit = none,
                               const QString& from = {});

    /*! \brief Construct a URL without creating a full-fledged job object
     *
     * This function can be used when a URL for GetThreadRootsJob
     * is necessary but the job itself isn't.
     */
    static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId,
                               const QString& include = {},
                               Omittable<int> limit = none,
                               const QString& from = {});

    // Result properties

    /// The thread roots, ordered by the `latest_event` in each event's
    /// aggregation bundle. All events returned include bundled
    /// [aggregations](/client-server-api/#aggregations).
    ///
    /// If the thread root event was sent by an [ignored
    /// user](/client-server-api/#ignoring-users), the event is returned
    /// redacted to the caller. This is to simulate the same behaviour of a
    /// client doing aggregation locally on the thread.
    RoomEvents chunk() { return takeFromJson<RoomEvents>("chunk"_ls); }

    /// A token to supply to `from` to keep paginating the responses. Not
    /// present when there are no further results.
    QString nextBatch() const { return loadFromJson<QString>("next_batch"_ls); }
};

} // namespace Quotient