libQuotient
A Qt library for building matrix clients
sync_filter.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/csapi/definitions/event_filter.h>
6 #include <Quotient/csapi/definitions/room_event_filter.h>
7 
8 #include <Quotient/converters.h>
9 
10 namespace Quotient {
11 //! Filters to be applied to room data.
12 struct QUOTIENT_API RoomFilter {
13  //! A list of room IDs to exclude. If this list is absent then no rooms are excluded. A matching
14  //! room will be excluded even if it is listed in the `'rooms'` filter. This filter is applied
15  //! before the filters in `ephemeral`, `state`, `timeline` or `account_data`
16  QStringList notRooms{};
17 
18  //! A list of room IDs to include. If this list is absent then all rooms are included. This
19  //! filter is applied before the filters in `ephemeral`, `state`, `timeline` or `account_data`
20  QStringList rooms{};
21 
22  //! The ephemeral events to include for rooms. These are the events that appear in the
23  //! `ephemeral` property in the `/sync` response.
24  RoomEventFilter ephemeral{};
25 
26  //! Include rooms that the user has left in the sync, default false
27  std::optional<bool> includeLeave{};
28 
29  //! The state events to include for rooms.
30  RoomEventFilter state{};
31 
32  //! The message and state update events to include for rooms.
33  RoomEventFilter timeline{};
34 
35  //! The per user account data to include for rooms.
36  RoomEventFilter accountData{};
37 };
38 
39 template <>
40 struct JsonObjectConverter<RoomFilter> {
41  static void dumpTo(QJsonObject& jo, const RoomFilter& pod)
42  {
43  addParam<IfNotEmpty>(jo, "not_rooms"_L1, pod.notRooms);
44  addParam<IfNotEmpty>(jo, "rooms"_L1, pod.rooms);
45  addParam<IfNotEmpty>(jo, "ephemeral"_L1, pod.ephemeral);
46  addParam<IfNotEmpty>(jo, "include_leave"_L1, pod.includeLeave);
47  addParam<IfNotEmpty>(jo, "state"_L1, pod.state);
48  addParam<IfNotEmpty>(jo, "timeline"_L1, pod.timeline);
49  addParam<IfNotEmpty>(jo, "account_data"_L1, pod.accountData);
50  }
51  static void fillFrom(const QJsonObject& jo, RoomFilter& pod)
52  {
53  fillFromJson(jo.value("not_rooms"_L1), pod.notRooms);
54  fillFromJson(jo.value("rooms"_L1), pod.rooms);
55  fillFromJson(jo.value("ephemeral"_L1), pod.ephemeral);
56  fillFromJson(jo.value("include_leave"_L1), pod.includeLeave);
57  fillFromJson(jo.value("state"_L1), pod.state);
58  fillFromJson(jo.value("timeline"_L1), pod.timeline);
59  fillFromJson(jo.value("account_data"_L1), pod.accountData);
60  }
61 };
62 
63 struct QUOTIENT_API Filter {
64  //! List of event fields to include. If this list is absent then all fields are included. The
65  //! entries are [dot-separated paths for each property](/appendices#dot-separated-property-paths)
66  //! to include. So ['content.body'] will include the 'body' field of the 'content' object. A
67  //! server may include more fields than were requested.
68  QStringList eventFields{};
69 
70  //! The format to use for events. 'client' will return the events in a format suitable for
71  //! clients. 'federation' will return the raw event as received over federation. The default is
72  //! 'client'.
73  QString eventFormat{};
74 
75  //! The presence updates to include.
76  EventFilter presence{};
77 
78  //! The user account data that isn't associated with rooms to include.
79  EventFilter accountData{};
80 
81  //! Filters to be applied to room data.
82  RoomFilter room{};
83 };
84 
85 template <>
86 struct JsonObjectConverter<Filter> {
87  static void dumpTo(QJsonObject& jo, const Filter& pod)
88  {
89  addParam<IfNotEmpty>(jo, "event_fields"_L1, pod.eventFields);
90  addParam<IfNotEmpty>(jo, "event_format"_L1, pod.eventFormat);
91  addParam<IfNotEmpty>(jo, "presence"_L1, pod.presence);
92  addParam<IfNotEmpty>(jo, "account_data"_L1, pod.accountData);
93  addParam<IfNotEmpty>(jo, "room"_L1, pod.room);
94  }
95  static void fillFrom(const QJsonObject& jo, Filter& pod)
96  {
97  fillFromJson(jo.value("event_fields"_L1), pod.eventFields);
98  fillFromJson(jo.value("event_format"_L1), pod.eventFormat);
99  fillFromJson(jo.value("presence"_L1), pod.presence);
100  fillFromJson(jo.value("account_data"_L1), pod.accountData);
101  fillFromJson(jo.value("room"_L1), pod.room);
102  }
103 };
104 
105 } // namespace Quotient