1 | /****************************************************************************** |
2 | * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN |
3 | */ |
4 | |
5 | #pragma once |
6 | |
7 | #include <Quotient/events/roomevent.h> |
8 | #include <Quotient/events/stateevent.h> |
9 | #include <Quotient/jobs/basejob.h> |
10 | |
11 | namespace Quotient { |
12 | |
13 | /*! \brief Get events and state around the specified event. |
14 | * |
15 | * This API returns a number of events that happened just before and |
16 | * after the specified event. This allows clients to get the context |
17 | * surrounding an event. |
18 | * |
19 | * *Note*: This endpoint supports lazy-loading of room member events. See |
20 | * [Lazy-loading room members](/client-server-api/#lazy-loading-room-members) |
21 | * for more information. |
22 | */ |
23 | class QUOTIENT_API GetEventContextJob : public BaseJob { |
24 | public: |
25 | /*! \brief Get events and state around the specified event. |
26 | * |
27 | * \param roomId |
28 | * The room to get events from. |
29 | * |
30 | * \param eventId |
31 | * The event to get context around. |
32 | * |
33 | * \param limit |
34 | * The maximum number of context events to return. The limit applies |
35 | * to the sum of the `events_before` and `events_after` arrays. The |
36 | * requested event ID is always returned in `event` even if `limit` is |
37 | * 0. Defaults to 10. |
38 | * |
39 | * \param filter |
40 | * A JSON `RoomEventFilter` to filter the returned events with. The |
41 | * filter is only applied to `events_before`, `events_after`, and |
42 | * `state`. It is not applied to the `event` itself. The filter may |
43 | * be applied before or/and after the `limit` parameter - whichever the |
44 | * homeserver prefers. |
45 | * |
46 | * See [Filtering](/client-server-api/#filtering) for more information. |
47 | */ |
48 | explicit GetEventContextJob(const QString& roomId, const QString& eventId, |
49 | Omittable<int> limit = none, |
50 | const QString& filter = {}); |
51 | |
52 | /*! \brief Construct a URL without creating a full-fledged job object |
53 | * |
54 | * This function can be used when a URL for GetEventContextJob |
55 | * is necessary but the job itself isn't. |
56 | */ |
57 | static QUrl makeRequestUrl(QUrl baseUrl, const QString& roomId, |
58 | const QString& eventId, |
59 | Omittable<int> limit = none, |
60 | const QString& filter = {}); |
61 | |
62 | // Result properties |
63 | |
64 | /// A token that can be used to paginate backwards with. |
65 | QString begin() const { return loadFromJson<QString>(keyName: "start"_ls ); } |
66 | |
67 | /// A token that can be used to paginate forwards with. |
68 | QString end() const { return loadFromJson<QString>(keyName: "end"_ls ); } |
69 | |
70 | /// A list of room events that happened just before the |
71 | /// requested event, in reverse-chronological order. |
72 | RoomEvents eventsBefore() |
73 | { |
74 | return takeFromJson<RoomEvents>(key: "events_before"_ls ); |
75 | } |
76 | |
77 | /// Details of the requested event. |
78 | RoomEventPtr event() { return takeFromJson<RoomEventPtr>(key: "event"_ls ); } |
79 | |
80 | /// A list of room events that happened just after the |
81 | /// requested event, in chronological order. |
82 | RoomEvents eventsAfter() |
83 | { |
84 | return takeFromJson<RoomEvents>(key: "events_after"_ls ); |
85 | } |
86 | |
87 | /// The state of the room at the last event returned. |
88 | StateEvents state() { return takeFromJson<StateEvents>(key: "state"_ls ); } |
89 | }; |
90 | |
91 | } // namespace Quotient |
92 | |