aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/message_pagination.h
blob: b0d95bad5246a3869652b58b5abefdbd086bf237 (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
77
78
79
80
81
82
/******************************************************************************
 * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
 */

#pragma once

#include "converters.h"

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

namespace Quotient {

// Operations

/*! \brief Get a list of events for this room
 *
 * This API returns a list of message and state events for a room. It uses
 * pagination query parameters to paginate history in the room.
 */
class GetRoomEventsJob : public BaseJob {
public:
    /*! \brief Get a list of events for this room
     *
     * \param roomId
     *   The room to get events from.
     * \param from
     *   The token to start returning events from. This token can be obtained
     *   from a ``prev_batch`` token returned for each room by the sync API,
     *   or from a ``start`` or ``end`` token returned by a previous request
     *   to this endpoint.
     * \param dir
     *   The direction to return events from.
     * \param to
     *   The token to stop returning events at. This token can be obtained from
     *   a ``prev_batch`` token returned for each room by the sync endpoint,
     *   or from a ``start`` or ``end`` token returned by a previous request to
     *   this endpoint.
     * \param limit
     *   The maximum number of events to return. Default: 10.
     * \param filter
     *   A JSON RoomEventFilter to filter returned events with.
     */
    explicit GetRoomEventsJob(const QString& roomId, const QString& from,
                              const QString& dir, const QString& to = {},
                              Omittable<int> limit = none,
                              const QString& filter = {});

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

    // Result properties

    /// The token the pagination starts from. If ``dir=b`` this will be
    /// the token supplied in ``from``.
    const QString& begin() const;

    /// The token the pagination ends at. If ``dir=b`` this token should
    /// be used again to request even earlier events.
    const QString& end() const;

    /// A list of room events.
    RoomEvents&& chunk();

protected:
    Status parseJson(const QJsonDocument& data) override;

private:
    class Private;
    QScopedPointer<Private> d;
};

} // namespace Quotient