1#pragma once
2
3/// @file
4/// @brief Notification related endpoints.
5
6#if __has_include(<nlohmann/json_fwd.hpp>)
7#include <nlohmann/json_fwd.hpp>
8#else
9#include <nlohmann/json.hpp>
10#endif
11
12#include "mtx/events/collections.hpp"
13#include "mtx/pushrules.hpp"
14
15namespace mtx {
16namespace responses {
17
18//! Description for a notification.
19struct Notification
20{
21 //! The action to perform when the conditions for this rule are met.
22 std::vector<mtx::pushrules::actions::Action> actions;
23 //! The Event object for the event that triggered the notification.
24 mtx::events::collections::TimelineEvents event;
25 //! Indicates whether the user has sent a read receipt indicating
26 //! that they have read this message.
27 bool read = false;
28 //! The profile tag of the rule that matched this event.
29 std::string profile_tag;
30 //! The ID of the room in which the event was posted.
31 std::string room_id;
32 //! The unix timestamp at which the event notification was sent, in milliseconds.
33 uint64_t ts;
34
35 friend void from_json(const nlohmann::json &obj, Notification &res);
36 friend void to_json(nlohmann::json &obj, const Notification &res);
37};
38
39//! Response from the `GET /_matrix/client/r0/notifications` endpoint.
40//
41//! The endpoint is used to paginate through the list of events
42//! that the user has been, or would have been notified about.
43struct Notifications
44{
45 //! The token to supply in the from param of the next /notifications
46 //! request in order to request more events. If this is absent,
47 //! there are no more results.
48 //! TODO: https://github.com/matrix-org/synapse/pull/3190
49 // std::string next_token;
50 //! The list of events that triggered notifications.
51 std::vector<Notification> notifications;
52
53 friend void from_json(const nlohmann::json &obj, Notifications &res);
54 friend void to_json(nlohmann::json &obj, const Notifications &res);
55};
56}
57}
58