libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
notifications.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/event.h>
6#include <Quotient/jobs/basejob.h>
7
8namespace Quotient {
9
10//! \brief Gets a list of events that the user has been notified about
11//!
12//! This API is used to paginate through the list of events that the
13//! user has been, or would have been notified about.
15public:
16 // Inner data structures
17
19 //! The action(s) to perform when the conditions for this rule are met.
20 //! See [Push Rules: API](/client-server-api/#push-rules-api).
22
23 //! The Event object for the event that triggered the notification.
25
26 //! Indicates whether the user has sent a read receipt indicating
27 //! that they have read this message.
28 bool read;
29
30 //! The ID of the room in which the event was posted.
32
33 //! The unix timestamp at which the event notification was sent,
34 //! in milliseconds.
36
37 //! The profile tag of the rule that matched this event.
39 };
40
41 // Construction/destruction
42
43 //! \param from
44 //! Pagination token to continue from. This should be the `next_token`
45 //! returned from an earlier call to this endpoint.
46 //!
47 //! \param limit
48 //! Limit on the number of events to return in this request.
49 //!
50 //! \param only
51 //! Allows basic filtering of events returned. Supply `highlight`
52 //! to return only events where the notification had the highlight
53 //! tweak set.
54 explicit GetNotificationsJob(const QString& from = {}, std::optional<int> limit = std::nullopt,
55 const QString& only = {});
56
57 //! \brief Construct a URL without creating a full-fledged job object
58 //!
59 //! This function can be used when a URL for GetNotificationsJob
60 //! is necessary but the job itself isn't.
62 std::optional<int> limit = std::nullopt, const QString& only = {});
63
64 // Result properties
65
66 //! The token to supply in the `from` param of the next
67 //! `/notifications` request in order to request more
68 //! events. If this is absent, there are no more results.
69 QString nextToken() const { return loadFromJson<QString>("next_token"_L1); }
70
71 //! The list of events that triggered notifications.
73 {
74 return takeFromJson<std::vector<Notification>>("notifications"_L1);
75 }
76
77 struct Response {
78 //! The token to supply in the `from` param of the next
79 //! `/notifications` request in order to request more
80 //! events. If this is absent, there are no more results.
82
83 //! The list of events that triggered notifications.
85 };
86};
87
89constexpr inline auto doCollectResponse<JobT> =
90 [](JobT* j) -> GetNotificationsJob::Response { return { j->nextToken(), j->notifications() }; };
91
92template <>
95 {
96 fillFromJson(jo.value("actions"_L1), result.actions);
97 fillFromJson(jo.value("event"_L1), result.event);
98 fillFromJson(jo.value("read"_L1), result.read);
99 fillFromJson(jo.value("room_id"_L1), result.roomId);
100 fillFromJson(jo.value("ts"_L1), result.ts);
101 fillFromJson(jo.value("profile_tag"_L1), result.profileTag);
102 }
103};
104
105} // namespace Quotient
Gets a list of events that the user has been notified about.
#define QUOTIENT_API