libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
create_room.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
/
jobs
/
basejob
.
h
>
6
7
namespace
Quotient
{
8
9
//! \brief Create a new room
10
//!
11
//! Create a new room with various configuration options.
12
//!
13
//! The server MUST apply the normal state resolution rules when creating
14
//! the new room, including checking power levels for each event. It MUST
15
//! apply the events implied by the request in the following order:
16
//!
17
//! 1. The `m.room.create` event itself. Must be the first event in the
18
//! room.
19
//!
20
//! 2. An `m.room.member` event for the creator to join the room. This is
21
//! needed so the remaining events can be sent.
22
//!
23
//! 3. A default `m.room.power_levels` event, giving the room creator
24
//! (and not other members) permission to send state events. Overridden
25
//! by the `power_level_content_override` parameter.
26
//!
27
//! 4. An `m.room.canonical_alias` event if `room_alias_name` is given.
28
//!
29
//! 5. Events set by the `preset`. Currently these are the `m.room.join_rules`,
30
//! `m.room.history_visibility`, and `m.room.guest_access` state events.
31
//!
32
//! 6. Events listed in `initial_state`, in the order that they are
33
//! listed.
34
//!
35
//! 7. Events implied by `name` and `topic` (`m.room.name` and `m.room.topic`
36
//! state events).
37
//!
38
//! 8. Invite events implied by `invite` and `invite_3pid` (`m.room.member` with
39
//! `membership: invite` and `m.room.third_party_invite`).
40
//!
41
//! The available presets do the following with respect to room state:
42
//!
43
//! | Preset | `join_rules` | `history_visibility` | `guest_access` | Other |
44
//! |------------------------|--------------|----------------------|----------------|-------|
45
//! | `private_chat` | `invite` | `shared` | `can_join` | |
46
//! | `trusted_private_chat` | `invite` | `shared` | `can_join` | All invitees
47
//! are given the same power level as the room creator. | | `public_chat` | `public` |
48
//! `shared` | `forbidden` | |
49
//!
50
//! The server will create a `m.room.create` event in the room with the
51
//! requesting user as the creator, alongside other keys provided in the
52
//! `creation_content`.
53
class
QUOTIENT_API
CreateRoomJob
:
public
BaseJob
{
54
public
:
55
// Inner data structures
56
57
struct
QUOTIENT_API
Invite3pid
{
58
//! The hostname+port of the identity server which should be used for third-party identifier
59
//! lookups.
60
QString
idServer
;
61
62
//! An access token previously registered with the identity server. Servers
63
//! can treat this as optional to distinguish between r0.5-compatible clients
64
//! and this specification version.
65
QString
idAccessToken
;
66
67
//! The kind of address being passed in the address field, for example `email`
68
//! (see [the list of recognised values](/appendices/#3pid-types)).
69
QString
medium
;
70
71
//! The invitee's third-party identifier.
72
QString
address
;
73
};
74
75
struct
QUOTIENT_API
StateEvent
{
76
//! The type of event to send.
77
QString
type
;
78
79
//! The content of the event.
80
QJsonObject
content
;
81
82
//! The state_key of the state event. Defaults to an empty string.
83
QString
stateKey
{};
84
};
85
86
// Construction/destruction
87
88
//! \param visibility
89
//! A `public` visibility indicates that the room will be shown
90
//! in the published room list. A `private` visibility will hide
91
//! the room from the published room list. Rooms default to
92
//! `private` visibility if this key is not included. NB: This
93
//! should not be confused with `join_rules` which also uses the
94
//! word `public`.
95
//!
96
//! \param roomAliasName
97
//! The desired room alias **local part**. If this is included, a
98
//! room alias will be created and mapped to the newly created
99
//! room. The alias will belong on the *same* homeserver which
100
//! created the room. For example, if this was set to "foo" and
101
//! sent to the homeserver "example.com" the complete room alias
102
//! would be `#foo:example.com`.
103
//!
104
//! The complete room alias will become the canonical alias for
105
//! the room and an `m.room.canonical_alias` event will be sent
106
//! into the room.
107
//!
108
//! \param name
109
//! If this is included, an `m.room.name` event will be sent
110
//! into the room to indicate the name of the room. See Room
111
//! Events for more information on `m.room.name`.
112
//!
113
//! \param topic
114
//! If this is included, an `m.room.topic` event will be sent
115
//! into the room to indicate the topic for the room. See Room
116
//! Events for more information on `m.room.topic`.
117
//!
118
//! \param invite
119
//! A list of user IDs to invite to the room. This will tell the
120
//! server to invite everyone in the list to the newly created room.
121
//!
122
//! \param invite3pid
123
//! A list of objects representing third-party IDs to invite into
124
//! the room.
125
//!
126
//! \param roomVersion
127
//! The room version to set for the room. If not provided, the homeserver is
128
//! to use its configured default. If provided, the homeserver will return a
129
//! 400 error with the errcode `M_UNSUPPORTED_ROOM_VERSION` if it does not
130
//! support the room version.
131
//!
132
//! \param creationContent
133
//! Extra keys, such as `m.federate`, to be added to the content
134
//! of the [`m.room.create`](/client-server-api/#mroomcreate) event. The server will overwrite
135
//! the following keys: `creator`, `room_version`. Future versions of the specification may
136
//! allow the server to overwrite other keys.
137
//!
138
//! \param initialState
139
//! A list of state events to set in the new room. This allows
140
//! the user to override the default state events set in the new
141
//! room. The expected format of the state events are an object
142
//! with type, state_key and content keys set.
143
//!
144
//! Takes precedence over events set by `preset`, but gets
145
//! overridden by `name` and `topic` keys.
146
//!
147
//! \param preset
148
//! Convenience parameter for setting various default state events
149
//! based on a preset.
150
//!
151
//! If unspecified, the server should use the `visibility` to determine
152
//! which preset to use. A visibility of `public` equates to a preset of
153
//! `public_chat` and `private` visibility equates to a preset of
154
//! `private_chat`.
155
//!
156
//! \param isDirect
157
//! This flag makes the server set the `is_direct` flag on the
158
//! `m.room.member` events sent to the users in `invite` and
159
//! `invite_3pid`. See [Direct Messaging](/client-server-api/#direct-messaging) for more
160
//! information.
161
//!
162
//! \param powerLevelContentOverride
163
//! The power level content to override in the default power level
164
//! event. This object is applied on top of the generated
165
//! [`m.room.power_levels`](/client-server-api/#mroompower_levels)
166
//! event content prior to it being sent to the room. Defaults to
167
//! overriding nothing.
168
explicit
CreateRoomJob
(
const
QString
&
visibility
= {},
const
QString
&
roomAliasName
= {},
169
const
QString
&
name
= {},
const
QString
&
topic
= {},
170
const
QStringList
&
invite
= {},
171
const
QVector
<
Invite3pid
>&
invite3pid
= {},
172
const
QString
&
roomVersion
= {},
const
QJsonObject
&
creationContent
= {},
173
const
QVector
<
StateEvent
>&
initialState
= {},
const
QString
&
preset
= {},
174
std
::
optional
<
bool
>
isDirect
=
std
::
nullopt
,
175
const
QJsonObject
&
powerLevelContentOverride
= {});
176
177
// Result properties
178
179
//! The created room's ID.
180
QString
roomId
()
const
{
return
loadFromJson
<
QString
>(
"room_id"_L1
); }
181
};
182
183
inline
auto
collectResponse
(
const
CreateRoomJob* job) {
return
job->roomId(); }
184
185
template
<>
186
struct
QUOTIENT_API
JsonObjectConverter
<
CreateRoomJob
::
Invite3pid
> {
187
static
void
dumpTo
(
QJsonObject
&
jo
,
const
CreateRoomJob
::
Invite3pid
&
pod
)
188
{
189
addParam
(
jo
,
"id_server"_L1
,
pod
.
idServer
);
190
addParam
(
jo
,
"id_access_token"_L1
,
pod
.
idAccessToken
);
191
addParam
(
jo
,
"medium"_L1
,
pod
.
medium
);
192
addParam
(
jo
,
"address"_L1
,
pod
.
address
);
193
}
194
};
195
196
template
<>
197
struct
QUOTIENT_API
JsonObjectConverter
<
CreateRoomJob
::
StateEvent
> {
198
static
void
dumpTo
(
QJsonObject
&
jo
,
const
CreateRoomJob
::
StateEvent
&
pod
)
199
{
200
addParam
(
jo
,
"type"_L1
,
pod
.
type
);
201
addParam
(
jo
,
"content"_L1
,
pod
.
content
);
202
addParam
<
IfNotEmpty
>(
jo
,
"state_key"_L1
,
pod
.
stateKey
);
203
}
204
};
205
206
}
// namespace Quotient
Quotient::CreateRoomJob
Create a new room.
Definition
create_room.h:53
Quotient
Definition
accountregistry.h:13
Quotient::collectResponse
auto collectResponse(const GetAccountDataJob *job)
Definition
account-data.h:59
QUOTIENT_API
#define QUOTIENT_API
Definition
quotient_export.h:22
Quotient
csapi
create_room.h
Generated by
1.9.8