1 | /****************************************************************************** |
2 | * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN |
3 | */ |
4 | |
5 | #pragma once |
6 | |
7 | #include <Quotient/converters.h> |
8 | |
9 | namespace Quotient { |
10 | |
11 | struct PublicRoomsChunk { |
12 | /// The number of members joined to the room. |
13 | int numJoinedMembers; |
14 | |
15 | /// The ID of the room. |
16 | QString roomId; |
17 | |
18 | /// Whether the room may be viewed by guest users without joining. |
19 | bool worldReadable; |
20 | |
21 | /// Whether guest users may join the room and participate in it. |
22 | /// If they can, they will be subject to ordinary power level |
23 | /// rules like any other user. |
24 | bool guestCanJoin; |
25 | |
26 | /// The canonical alias of the room, if any. |
27 | QString canonicalAlias{}; |
28 | |
29 | /// The name of the room, if any. |
30 | QString name{}; |
31 | |
32 | /// The topic of the room, if any. |
33 | QString topic{}; |
34 | |
35 | /// The URL for the room's avatar, if one is set. |
36 | QUrl avatarUrl{}; |
37 | |
38 | /// The `type` of room (from |
39 | /// [`m.room.create`](/client-server-api/#mroomcreate)), if any. |
40 | QString roomType{}; |
41 | |
42 | /// The room's join rule. When not present, the room is assumed to |
43 | /// be `public`. Note that rooms with `invite` join rules are not |
44 | /// expected here, but rooms with `knock` rules are given their |
45 | /// near-public nature. |
46 | QString joinRule{}; |
47 | }; |
48 | |
49 | template <> |
50 | struct JsonObjectConverter<PublicRoomsChunk> { |
51 | static void dumpTo(QJsonObject& jo, const PublicRoomsChunk& pod) |
52 | { |
53 | addParam<>(container&: jo, QStringLiteral("num_joined_members" ), |
54 | value: pod.numJoinedMembers); |
55 | addParam<>(container&: jo, QStringLiteral("room_id" ), value: pod.roomId); |
56 | addParam<>(container&: jo, QStringLiteral("world_readable" ), value: pod.worldReadable); |
57 | addParam<>(container&: jo, QStringLiteral("guest_can_join" ), value: pod.guestCanJoin); |
58 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("canonical_alias" ), |
59 | value: pod.canonicalAlias); |
60 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("name" ), value: pod.name); |
61 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("topic" ), value: pod.topic); |
62 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("avatar_url" ), value: pod.avatarUrl); |
63 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("room_type" ), value: pod.roomType); |
64 | addParam<IfNotEmpty>(container&: jo, QStringLiteral("join_rule" ), value: pod.joinRule); |
65 | } |
66 | static void fillFrom(const QJsonObject& jo, PublicRoomsChunk& pod) |
67 | { |
68 | fillFromJson(jv: jo.value(key: "num_joined_members"_ls ), pod&: pod.numJoinedMembers); |
69 | fillFromJson(jv: jo.value(key: "room_id"_ls ), pod&: pod.roomId); |
70 | fillFromJson(jv: jo.value(key: "world_readable"_ls ), pod&: pod.worldReadable); |
71 | fillFromJson(jv: jo.value(key: "guest_can_join"_ls ), pod&: pod.guestCanJoin); |
72 | fillFromJson(jv: jo.value(key: "canonical_alias"_ls ), pod&: pod.canonicalAlias); |
73 | fillFromJson(jv: jo.value(key: "name"_ls ), pod&: pod.name); |
74 | fillFromJson(jv: jo.value(key: "topic"_ls ), pod&: pod.topic); |
75 | fillFromJson(jv: jo.value(key: "avatar_url"_ls ), pod&: pod.avatarUrl); |
76 | fillFromJson(jv: jo.value(key: "room_type"_ls ), pod&: pod.roomType); |
77 | fillFromJson(jv: jo.value(key: "join_rule"_ls ), pod&: pod.joinRule); |
78 | } |
79 | }; |
80 | |
81 | } // namespace Quotient |
82 | |