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