diff --git a/lib/matrix_api_lite/generated/api.dart b/lib/matrix_api_lite/generated/api.dart index c571cf34..f01ad0e6 100644 --- a/lib/matrix_api_lite/generated/api.dart +++ b/lib/matrix_api_lite/generated/api.dart @@ -34,6 +34,12 @@ class Api { /// suitably namespaced for each application and reduces the risk of /// clashes. /// + /// **NOTE:** + /// This endpoint should be accessed with the hostname of the homeserver's + /// [server name](https://spec.matrix.org/unstable/appendices/#server-name) by making a + /// GET request to `https://hostname/.well-known/matrix/client`. + /// + /// /// Note that this endpoint is not necessarily handled by the homeserver, /// but by another webserver, to be used for discovering the homeserver URL. Future getWellknown() async { @@ -49,10 +55,13 @@ class Api { /// Gets server admin contact and support page of the domain. /// - /// Like the [well-known discovery URI](https://spec.matrix.org/unstable/client-server-api/#well-known-uri), - /// this should be accessed with the hostname of the homeserver by making a + /// **NOTE:** + /// Like the [well-known discovery URI](https://spec.matrix.org/unstable/client-server-api/#well-known-uris), + /// this endpoint should be accessed with the hostname of the homeserver's + /// [server name](https://spec.matrix.org/unstable/appendices/#server-name) by making a /// GET request to `https://hostname/.well-known/matrix/support`. /// + /// /// Note that this endpoint is not necessarily handled by the homeserver. /// It may be served by another webserver, used for discovering support /// information for the homeserver. @@ -112,6 +121,36 @@ class Api { return json['duration_ms'] as int; } + /// Gets the OAuth 2.0 authorization server metadata, as defined in + /// [RFC 8414](https://datatracker.ietf.org/doc/html/rfc8414), including the + /// endpoint URLs and the supported parameters that can be used by the + /// clients. + /// + /// This endpoint definition includes only the fields that are meaningful in + /// the context of the Matrix specification. The full list of possible + /// fields is available in the [OAuth Authorization Server Metadata + /// registry](https://www.iana.org/assignments/oauth-parameters/oauth-parameters.xhtml#authorization-server-metadata), + /// and normative definitions of them are available in their respective + /// RFCs. + /// + /// **NOTE:** + /// The authorization server metadata is relatively large and may change + /// over time. Clients should: + /// + /// - Cache the metadata appropriately based on HTTP caching headers + /// - Refetch the metadata if it is stale + /// + Future getAuthMetadata() async { + final requestUri = Uri(path: '_matrix/client/v1/auth_metadata'); + final request = Request('GET', baseUri!.resolveUri(requestUri)); + final response = await httpClient.send(request); + final responseBody = await response.stream.toBytes(); + if (response.statusCode != 200) unexpectedResponse(response, responseBody); + final responseString = utf8.decode(responseBody); + final json = jsonDecode(responseString); + return GetAuthMetadataResponse.fromJson(json as Map); + } + /// Optional endpoint - the server is not required to implement this endpoint if it does not /// intend to use or support this functionality. /// @@ -169,12 +208,12 @@ class Api { /// All values are intentionally left optional. Clients SHOULD follow /// the advice given in the field description when the field is not available. /// - /// {{% boxes/note %}} + /// **NOTE:** /// Both clients and server administrators should be aware that proxies /// between the client and the server may affect the apparent behaviour of content /// repository APIs, for example, proxies may enforce a lower upload size limit /// than is advertised by the server on this endpoint. - /// {{% /boxes/note %}} + /// Future getConfigAuthed() async { final requestUri = Uri(path: '_matrix/client/v1/media/config'); final request = Request('GET', baseUri!.resolveUri(requestUri)); @@ -187,11 +226,11 @@ class Api { return MediaConfig.fromJson(json as Map); } - /// {{% boxes/note %}} + /// **NOTE:** /// Clients SHOULD NOT generate or use URLs which supply the access token in /// the query string. These URLs may be copied by users verbatim and provided /// in a chat message to another user, disclosing the sender's access token. - /// {{% /boxes/note %}} + /// /// /// Clients MAY be redirected using the 307/308 responses below to download /// the request object. This is typical when the homeserver uses a Content @@ -236,11 +275,11 @@ class Api { /// the previous endpoint) but replaces the target file name with the one /// provided by the caller. /// - /// {{% boxes/note %}} + /// **NOTE:** /// Clients SHOULD NOT generate or use URLs which supply the access token in /// the query string. These URLs may be copied by users verbatim and provided /// in a chat message to another user, disclosing the sender's access token. - /// {{% /boxes/note %}} + /// /// /// Clients MAY be redirected using the 307/308 responses below to download /// the request object. This is typical when the homeserver uses a Content @@ -287,12 +326,12 @@ class Api { /// Get information about a URL for the client. Typically this is called when a /// client sees a URL in a message and wants to render a preview for the user. /// - /// {{% boxes/note %}} + /// **NOTE:** /// Clients should consider avoiding this endpoint for URLs posted in encrypted /// rooms. Encrypted rooms often contain more sensitive information the users /// do not want to share with the homeserver, and this can mean that the URLs /// being shared should also not be shared with the homeserver. - /// {{% /boxes/note %}} + /// /// /// [url] The URL to get a preview of. /// @@ -320,11 +359,11 @@ class Api { /// Download a thumbnail of content from the content repository. /// See the [Thumbnails](https://spec.matrix.org/unstable/client-server-api/#thumbnails) section for more information. /// - /// {{% boxes/note %}} + /// **NOTE:** /// Clients SHOULD NOT generate or use URLs which supply the access token in /// the query string. These URLs may be copied by users verbatim and provided /// in a chat message to another user, disclosing the sender's access token. - /// {{% /boxes/note %}} + /// /// /// Clients MAY be redirected using the 307/308 responses below to download /// the request object. This is typical when the homeserver uses a Content @@ -427,6 +466,48 @@ class Api { return json['valid'] as bool; } + /// Retrieves a summary for a room. + /// + /// Clients should note that requests for rooms where the user's membership + /// is `invite` or `knock` might yield outdated, partial or even no data + /// since the server may not have access to the current state of the room. + /// + /// Servers MAY allow unauthenticated access to this API if at least one of + /// the following conditions holds true: + /// + /// - The room has a [join rule](#mroomjoin_rules) of `public`, `knock` or + /// `knock_restricted`. + /// - The room has a `world_readable` [history visibility](#room-history-visibility). + /// + /// Servers should consider rate limiting requests that require a federation + /// request more heavily if the client is unauthenticated. + /// + /// [roomIdOrAlias] The room identifier or alias to summarise. + /// + /// [via] The servers to attempt to request the summary from when + /// the local server cannot generate it (for instance, because + /// it has no local user in the room). + Future getRoomSummary( + String roomIdOrAlias, { + List? via, + }) async { + final requestUri = Uri( + path: + '_matrix/client/v1/room_summary/${Uri.encodeComponent(roomIdOrAlias)}', + queryParameters: { + if (via != null) 'via': via, + }, + ); + final request = Request('GET', baseUri!.resolveUri(requestUri)); + request.headers['authorization'] = 'Bearer ${bearerToken!}'; + final response = await httpClient.send(request); + final responseBody = await response.stream.toBytes(); + if (response.statusCode != 200) unexpectedResponse(response, responseBody); + final responseString = utf8.decode(responseBody); + final json = jsonDecode(responseString); + return GetRoomSummaryResponse$3.fromJson(json as Map); + } + /// Paginates over the space tree in a depth-first manner to locate child rooms of a given space. /// /// Where a child room is unknown to the local server, federation is used to fill in the details. @@ -915,6 +996,11 @@ class Api { /// Homeservers should prevent the caller from adding a 3PID to their account if it has /// already been added to another user's account on the homeserver. /// + /// **WARNING:** + /// Since this endpoint uses User-Interactive Authentication, it cannot be used when the access token was obtained + /// via the [OAuth 2.0 API](https://spec.matrix.org/unstable/client-server-api/#oauth-20-api). + /// + /// /// [auth] Additional authentication information for the /// user-interactive authentication API. /// @@ -1588,9 +1674,23 @@ class Api { /// 2. An `m.room.member` event for the creator to join the room. This is /// needed so the remaining events can be sent. /// - /// 3. A default `m.room.power_levels` event, giving the room creator - /// (and not other members) permission to send state events. Overridden - /// by the `power_level_content_override` parameter. + /// 3. A default `m.room.power_levels` event. Overridden by the + /// `power_level_content_override` parameter. + /// + /// In [room versions](https://spec.matrix.org/unstable/rooms) 1 through 11, the room creator (and not + /// other members) will be given permission to send state events. + /// + /// In room versions 12 and later, the room creator is given infinite + /// power level and cannot be specified in the `users` field of + /// `m.room.power_levels`, so is not listed explicitly. + /// + /// **Note**: For `trusted_private_chat`, the users specified in the + /// `invite` parameter SHOULD also be appended to `additional_creators` + /// by the server, per the `creation_content` parameter. + /// + /// If the room's version is 12 or higher, the power level for sending + /// `m.room.tombstone` events MUST explicitly be higher than `state_default`. + /// For example, set to 150 instead of 100. /// /// 4. An `m.room.canonical_alias` event if `room_alias_name` is given. /// @@ -1616,13 +1716,20 @@ class Api { /// /// The server will create a `m.room.create` event in the room with the /// requesting user as the creator, alongside other keys provided in the - /// `creation_content`. + /// `creation_content` or implied by behaviour of `creation_content`. /// /// [creationContent] Extra keys, such as `m.federate`, to be added to the content - /// of the [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate) event. The server will overwrite the following + /// of the [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate) event. + /// + /// The server will overwrite the following /// keys: `creator`, `room_version`. Future versions of the specification /// may allow the server to overwrite other keys. /// + /// When using the `trusted_private_chat` preset, the server SHOULD combine + /// `additional_creators` specified here and the `invite` array into the + /// eventual `m.room.create` event's `additional_creators`, deduplicating + /// between the two parameters. + /// /// [initialState] A list of state events to set in the new room. This allows /// the user to override the default state events set in the new /// room. The expected format of the state events are an object @@ -1641,9 +1748,10 @@ class Api { /// `m.room.member` events sent to the users in `invite` and /// `invite_3pid`. See [Direct Messaging](https://spec.matrix.org/unstable/client-server-api/#direct-messaging) for more information. /// - /// [name] If this is included, an `m.room.name` event will be sent - /// into the room to indicate the name of the room. See Room - /// Events for more information on `m.room.name`. + /// [name] If this is included, an [`m.room.name`](https://spec.matrix.org/unstable/client-server-api/#mroomname) event + /// will be sent into the room to indicate the name for the room. + /// This overwrites any [`m.room.name`](https://spec.matrix.org/unstable/client-server-api/#mroomname) + /// event in `initial_state`. /// /// [powerLevelContentOverride] The power level content to override in the default power level /// event. This object is applied on top of the generated @@ -1675,16 +1783,14 @@ class Api { /// 400 error with the errcode `M_UNSUPPORTED_ROOM_VERSION` if it does not /// support the room version. /// - /// [topic] If this is included, an `m.room.topic` event will be sent - /// into the room to indicate the topic for the room. See Room - /// Events for more information on `m.room.topic`. + /// [topic] If this is included, an [`m.room.topic`](https://spec.matrix.org/unstable/client-server-api/#mroomtopic) + /// event with a `text/plain` mimetype will be sent into the room + /// to indicate the topic for the room. This overwrites any + /// [`m.room.topic`](https://spec.matrix.org/unstable/client-server-api/#mroomtopic) event in `initial_state`. /// - /// [visibility] A `public` visibility indicates that the room will be shown - /// in the published room list. A `private` visibility will hide - /// the room from the published room list. Rooms default to - /// `private` visibility if this key is not included. NB: This - /// should not be confused with `join_rules` which also uses the - /// word `public`. + /// [visibility] The room's visibility in the server's + /// [published room directory](https://spec.matrix.org/unstable/client-server-api#published-room-directory). + /// Defaults to `private`. /// /// returns `room_id`: /// The created room's ID. @@ -1737,6 +1843,11 @@ class Api { /// /// Deletes the given devices, and invalidates any access token associated with them. /// + /// **WARNING:** + /// Since this endpoint uses User-Interactive Authentication, it cannot be used when the access token was obtained + /// via the [OAuth 2.0 API](https://spec.matrix.org/unstable/client-server-api/#oauth-20-api). + /// + /// /// [auth] Additional authentication information for the /// user-interactive authentication API. /// @@ -1787,6 +1898,11 @@ class Api { /// /// Deletes the given device, and invalidates any access token associated with it. /// + /// **WARNING:** + /// Since this endpoint uses User-Interactive Authentication, it cannot be used when the access token was obtained + /// via the [OAuth 2.0 API](https://spec.matrix.org/unstable/client-server-api/#oauth-20-api). + /// + /// /// [deviceId] The device to delete. /// /// [auth] Additional authentication information for the @@ -1851,11 +1967,12 @@ class Api { return ignore(json); } - /// Updates the visibility of a given room on the application service's room - /// directory. + /// Updates the visibility of a given room in the application service's + /// published room directory. /// - /// This API is similar to the room directory visibility API used by clients - /// to update the homeserver's more general room directory. + /// This API is similar to the + /// [visibility API](https://spec.matrix.org/unstable/client-server-api#put_matrixclientv3directorylistroomroomid) + /// used by clients to update the homeserver's more general published room directory. /// /// This API requires the use of an application service access token (`as_token`) /// instead of a typical client's access_token. This API cannot be invoked by @@ -1894,7 +2011,8 @@ class Api { return json as Map; } - /// Gets the visibility of a given room on the server's public room directory. + /// Gets the visibility of a given room in the server's + /// published room directory. /// /// [roomId] The room ID. /// @@ -1916,17 +2034,16 @@ class Api { : null)(json['visibility']); } - /// Sets the visibility of a given room in the server's public room - /// directory. + /// Sets the visibility of a given room in the server's published room directory. /// - /// Servers may choose to implement additional access control checks - /// here, for instance that room visibility can only be changed by - /// the room creator or a server administrator. + /// Servers MAY implement additional access control checks, for instance, + /// to ensure that a room's visibility can only be changed by the room creator + /// or a server administrator. /// /// [roomId] The room ID. /// /// [visibility] The new visibility setting for the room. - /// Defaults to 'public'. + /// Defaults to `public`. Future setRoomVisibilityOnDirectory( String roomId, { Visibility? visibility, @@ -2296,6 +2413,11 @@ class Api { /// makes this endpoint idempotent in the case where the response is lost over the network, /// which would otherwise cause a UIA challenge upon retry. /// + /// **WARNING:** + /// When this endpoint requires User-Interactive Authentication, it cannot be used when the access token was obtained + /// via the [OAuth 2.0 API](https://spec.matrix.org/unstable/client-server-api/#oauth-20-api). + /// + /// /// [auth] Additional authentication information for the /// user-interactive authentication API. /// @@ -2639,7 +2761,7 @@ class Api { /// deleted alongside the device. /// /// This endpoint does not use the [User-Interactive Authentication API](https://spec.matrix.org/unstable/client-server-api/#user-interactive-authentication-api) because - /// User-Interactive Authentication is designed to protect against attacks where the + /// User-Interactive Authentication is designed to protect against attacks where /// someone gets hold of a single access token then takes over the account. This /// endpoint invalidates all access tokens for the user, including the token used in /// the request, and therefore the attacker is unable to take over the account in @@ -2742,9 +2864,7 @@ class Api { return ignore(json); } - /// Get the combined profile information for this user. This API may be used - /// to fetch the user's own profile information or other users; either - /// locally or on remote homeservers. + /// Get the complete profile for a user. /// /// [userId] The user whose profile information to get. Future getUserProfile(String userId) async { @@ -2762,18 +2882,41 @@ class Api { return ProfileInformation.fromJson(json as Map); } - /// Get the user's avatar URL. This API may be used to fetch the user's - /// own avatar URL or to query the URL of other users; either locally or - /// on remote homeservers. + /// Remove a specific field from a user's profile. /// - /// [userId] The user whose avatar URL to get. + /// [userId] The user whose profile field should be deleted. /// - /// returns `avatar_url`: - /// The user's avatar URL if they have set one, otherwise not present. - Future getAvatarUrl(String userId) async { + /// [keyName] The name of the profile field to delete. + Future> deleteProfileField( + String userId, + String keyName, + ) async { final requestUri = Uri( path: - '_matrix/client/v3/profile/${Uri.encodeComponent(userId)}/avatar_url', + '_matrix/client/v3/profile/${Uri.encodeComponent(userId)}/${Uri.encodeComponent(keyName)}', + ); + final request = Request('DELETE', baseUri!.resolveUri(requestUri)); + request.headers['authorization'] = 'Bearer ${bearerToken!}'; + final response = await httpClient.send(request); + final responseBody = await response.stream.toBytes(); + if (response.statusCode != 200) unexpectedResponse(response, responseBody); + final responseString = utf8.decode(responseBody); + final json = jsonDecode(responseString); + return json as Map; + } + + /// Get the value of a profile field for a user. + /// + /// [userId] The user whose profile field should be returned. + /// + /// [keyName] The name of the profile field to retrieve. + Future> getProfileField( + String userId, + String keyName, + ) async { + final requestUri = Uri( + path: + '_matrix/client/v3/profile/${Uri.encodeComponent(userId)}/${Uri.encodeComponent(keyName)}', ); final request = Request('GET', baseUri!.resolveUri(requestUri)); if (bearerToken != null) { @@ -2784,90 +2927,44 @@ class Api { if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return ((v) => - v != null ? Uri.parse(v as String) : null)(json['avatar_url']); + return json as Map; } - /// This API sets the given user's avatar URL. You must have permission to - /// set this user's avatar URL, e.g. you need to have their `access_token`. + /// Set or update a profile field for a user. Must be authenticated with an + /// access token authorised to make changes. Servers MAY impose size limits + /// on individual fields, and the total profile MUST be under 64 KiB. /// - /// [userId] The user whose avatar URL to set. + /// Servers MAY reject `null` values. Servers that accept `null` values SHOULD store + /// them rather than treating `null` as a deletion request. Clients that want to delete a + /// field, including its key and value, SHOULD use the `DELETE` endpoint instead. /// - /// [avatarUrl] The new avatar URL for this user. - Future setAvatarUrl(String userId, Uri? avatarUrl) async { + /// [userId] The user whose profile field should be set. + /// + /// [keyName] The name of the profile field to set. This MUST be either `avatar_url`, `displayname`, `m.tz`, or a custom field following the [Common Namespaced Identifier Grammar](https://spec.matrix.org/unstable/appendices/#common-namespaced-identifier-grammar). + /// + /// [body] A JSON object containing the property whose name matches the `keyName` specified in the URL. See `additionalProperties` for further details. + Future> setProfileField( + String userId, + String keyName, + Map body, + ) async { final requestUri = Uri( path: - '_matrix/client/v3/profile/${Uri.encodeComponent(userId)}/avatar_url', + '_matrix/client/v3/profile/${Uri.encodeComponent(userId)}/${Uri.encodeComponent(keyName)}', ); final request = Request('PUT', baseUri!.resolveUri(requestUri)); request.headers['authorization'] = 'Bearer ${bearerToken!}'; request.headers['content-type'] = 'application/json'; - request.bodyBytes = utf8.encode( - jsonEncode({ - if (avatarUrl != null) 'avatar_url': avatarUrl.toString(), - }), - ); + request.bodyBytes = utf8.encode(jsonEncode(body)); final response = await httpClient.send(request); final responseBody = await response.stream.toBytes(); if (response.statusCode != 200) unexpectedResponse(response, responseBody); final responseString = utf8.decode(responseBody); final json = jsonDecode(responseString); - return ignore(json); + return json as Map; } - /// Get the user's display name. This API may be used to fetch the user's - /// own displayname or to query the name of other users; either locally or - /// on remote homeservers. - /// - /// [userId] The user whose display name to get. - /// - /// returns `displayname`: - /// The user's display name if they have set one, otherwise not present. - Future getDisplayName(String userId) async { - final requestUri = Uri( - path: - '_matrix/client/v3/profile/${Uri.encodeComponent(userId)}/displayname', - ); - final request = Request('GET', baseUri!.resolveUri(requestUri)); - if (bearerToken != null) { - request.headers['authorization'] = 'Bearer ${bearerToken!}'; - } - final response = await httpClient.send(request); - final responseBody = await response.stream.toBytes(); - if (response.statusCode != 200) unexpectedResponse(response, responseBody); - final responseString = utf8.decode(responseBody); - final json = jsonDecode(responseString); - return ((v) => v != null ? v as String : null)(json['displayname']); - } - - /// This API sets the given user's display name. You must have permission to - /// set this user's display name, e.g. you need to have their `access_token`. - /// - /// [userId] The user whose display name to set. - /// - /// [displayname] The new display name for this user. - Future setDisplayName(String userId, String? displayname) async { - final requestUri = Uri( - path: - '_matrix/client/v3/profile/${Uri.encodeComponent(userId)}/displayname', - ); - final request = Request('PUT', baseUri!.resolveUri(requestUri)); - request.headers['authorization'] = 'Bearer ${bearerToken!}'; - request.headers['content-type'] = 'application/json'; - request.bodyBytes = utf8.encode( - jsonEncode({ - if (displayname != null) 'displayname': displayname, - }), - ); - final response = await httpClient.send(request); - final responseBody = await response.stream.toBytes(); - if (response.statusCode != 200) unexpectedResponse(response, responseBody); - final responseString = utf8.decode(responseBody); - final json = jsonDecode(responseString); - return ignore(json); - } - - /// Lists the public rooms on the server. + /// Lists a server's published room directory. /// /// This API returns paginated responses. The rooms are ordered by the number /// of joined members, with the largest rooms first. @@ -2879,8 +2976,8 @@ class Api { /// The direction of pagination is specified solely by which token /// is supplied, rather than via an explicit flag. /// - /// [server] The server to fetch the public room lists from. Defaults to the - /// local server. Case sensitive. + /// [server] The server to fetch the published room directory from. Defaults + /// to the local server. Case sensitive. Future getPublicRooms({ int? limit, String? since, @@ -2903,13 +3000,13 @@ class Api { return GetPublicRoomsResponse.fromJson(json as Map); } - /// Lists the public rooms on the server, with optional filter. + /// Lists a server's published room directory with an optional filter. /// /// This API returns paginated responses. The rooms are ordered by the number /// of joined members, with the largest rooms first. /// - /// [server] The server to fetch the public room lists from. Defaults to the - /// local server. Case sensitive. + /// [server] The server to fetch the published room directory from. Defaults + /// to the local server. Case sensitive. /// /// [filter] Filter to apply to the results. /// @@ -4134,9 +4231,6 @@ class Api { /// /// - The matrix user ID who invited them to the room /// - /// If a token is requested from the identity server, the homeserver will - /// append a `m.room.third_party_invite` event to the room. - /// /// [roomId] The room identifier (not alias) to which to invite the user. /// /// [body] @@ -4739,14 +4833,23 @@ class Api { /// /// [stateKey] The key of the state to look up. Defaults to an empty string. When /// an empty string, the trailing slash on this endpoint is optional. + /// + /// [format] The format to use for the returned data. `content` (the default) will + /// return only the content of the state event. `event` will return the entire + /// event in the usual format suitable for clients, including fields like event + /// ID, sender and timestamp. Future> getRoomStateWithKey( String roomId, String eventType, - String stateKey, - ) async { + String stateKey, { + Format? format, + }) async { final requestUri = Uri( path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/state/${Uri.encodeComponent(eventType)}/${Uri.encodeComponent(stateKey)}', + queryParameters: { + if (format != null) 'format': format.name, + }, ); final request = Request('GET', baseUri!.resolveUri(requestUri)); request.headers['authorization'] = 'Bearer ${bearerToken!}'; @@ -4886,11 +4989,26 @@ class Api { /// /// [roomId] The ID of the room to upgrade. /// + /// [additionalCreators] When upgrading to a [room version](https://spec.matrix.org/unstable/rooms) which supports additional creators, + /// the [user IDs](https://spec.matrix.org/unstable/appendices#user-identifiers) which should be considered room + /// creators in addition to the user performing the upgrade. + /// + /// If the room being upgraded has additional creators, they are *not* automatically + /// copied to the new room. The full set of additional creators needs to be set to + /// retain (or add/remove) more room creators. + /// + /// When upgrading to a room version which doesn't support additional creators, this + /// field is ignored and has no effect during the upgrade process. + /// /// [newVersion] The new version for the room. /// /// returns `replacement_room`: /// The ID of the new room. - Future upgradeRoom(String roomId, String newVersion) async { + Future upgradeRoom( + String roomId, + String newVersion, { + List? additionalCreators, + }) async { final requestUri = Uri( path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/upgrade', ); @@ -4899,6 +5017,8 @@ class Api { request.headers['content-type'] = 'application/json'; request.bodyBytes = utf8.encode( jsonEncode({ + if (additionalCreators != null) + 'additional_creators': additionalCreators.map((v) => v).toList(), 'new_version': newVersion, }), ); @@ -5043,12 +5163,32 @@ class Api { /// /// By default, this is `0`, so the server will return immediately /// even if the response is empty. + /// + /// [useStateAfter] Controls whether to receive state changes between the previous sync + /// and the **start** of the timeline, or between the previous sync and + /// the **end** of the timeline. + /// + /// If this is set to `true`, servers MUST respond with the state + /// between the previous sync and the **end** of the timeline in + /// `state_after` and MUST omit `state`. + /// + /// If `false`, servers MUST respond with the state between the previous + /// sync and the **start** of the timeline in `state` and MUST omit + /// `state_after`. + /// + /// Even if this is set to `true`, clients MUST update their local state + /// with events in `state` and `timeline` if `state_after` is missing in + /// the response, for compatibility with servers that don't support this + /// parameter. + /// + /// By default, this is `false`. Future sync({ String? filter, String? since, bool? fullState, PresenceType? setPresence, int? timeout, + bool? useStateAfter, }) async { final requestUri = Uri( path: '_matrix/client/v3/sync', @@ -5058,6 +5198,7 @@ class Api { if (fullState != null) 'full_state': fullState.toString(), if (setPresence != null) 'set_presence': setPresence.name, if (timeout != null) 'timeout': timeout.toString(), + if (useStateAfter != null) 'use_state_after': useStateAfter.toString(), }, ); final request = Request('GET', baseUri!.resolveUri(requestUri)); @@ -5507,10 +5648,17 @@ class Api { return ignore(json); } - /// Performs a search for users. The homeserver may - /// determine which subset of users are searched, however the homeserver - /// MUST at a minimum consider the users the requesting user shares a - /// room with and those who reside in public rooms (known to the homeserver). + /// Performs a search for users. The homeserver may determine which + /// subset of users are searched. However, the homeserver MUST at a + /// minimum consider users who are visible to the requester based + /// on their membership in rooms known to the homeserver. This means: + /// + /// - users that share a room with the requesting user + /// - users who are joined to rooms known to the homeserver that have a + /// `public` [join rule](#mroomjoin_rules) + /// - users who are joined to rooms known to the homeserver that have a + /// `world_readable` [history visibility](#room-history-visibility) + /// /// The search MUST consider local users to the homeserver, and SHOULD /// query remote users as part of the search. /// @@ -5663,9 +5811,9 @@ class Api { return CreateContentResponse.fromJson(json as Map); } - /// {{% boxes/note %}} + /// **NOTE:** /// Replaced by [`GET /_matrix/client/v1/media/config`](https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv1mediaconfig). - /// {{% /boxes/note %}} + /// /// /// This endpoint allows clients to retrieve the configuration of the content /// repository, such as upload limitations. @@ -5690,17 +5838,17 @@ class Api { return MediaConfig.fromJson(json as Map); } - /// {{% boxes/note %}} + /// **NOTE:** /// Replaced by [`GET /_matrix/client/v1/media/download/{serverName}/{mediaId}`](https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv1mediadownloadservernamemediaid) /// (requires authentication). - /// {{% /boxes/note %}} /// - /// {{% boxes/warning %}} - /// {{% changed-in v="1.11" %}} This endpoint MAY return `404 M_NOT_FOUND` + /// + /// **WARNING:** + /// **[Changed in `v1.11`]** This endpoint MAY return `404 M_NOT_FOUND` /// for media which exists, but is after the server froze unauthenticated /// media access. See [Client Behaviour](https://spec.matrix.org/unstable/client-server-api/#content-repo-client-behaviour) for more /// information. - /// {{% /boxes/warning %}} + /// /// /// [serverName] The server name from the `mxc://` URI (the authority component). /// @@ -5752,21 +5900,21 @@ class Api { ); } - /// {{% boxes/note %}} + /// **NOTE:** /// Replaced by [`GET /_matrix/client/v1/media/download/{serverName}/{mediaId}/{fileName}`](https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv1mediadownloadservernamemediaidfilename) /// (requires authentication). - /// {{% /boxes/note %}} + /// /// /// This will download content from the content repository (same as /// the previous endpoint) but replace the target file name with the one /// provided by the caller. /// - /// {{% boxes/warning %}} - /// {{% changed-in v="1.11" %}} This endpoint MAY return `404 M_NOT_FOUND` + /// **WARNING:** + /// **[Changed in `v1.11`]** This endpoint MAY return `404 M_NOT_FOUND` /// for media which exists, but is after the server froze unauthenticated /// media access. See [Client Behaviour](https://spec.matrix.org/unstable/client-server-api/#content-repo-client-behaviour) for more /// information. - /// {{% /boxes/warning %}} + /// /// /// [serverName] The server name from the `mxc://` URI (the authority component). /// @@ -5821,9 +5969,9 @@ class Api { ); } - /// {{% boxes/note %}} + /// **NOTE:** /// Replaced by [`GET /_matrix/client/v1/media/preview_url`](https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv1mediapreview_url). - /// {{% /boxes/note %}} + /// /// /// Get information about a URL for the client. Typically this is called when a /// client sees a URL in a message and wants to render a preview for the user. @@ -5858,20 +6006,20 @@ class Api { return PreviewForUrl.fromJson(json as Map); } - /// {{% boxes/note %}} + /// **NOTE:** /// Replaced by [`GET /_matrix/client/v1/media/thumbnail/{serverName}/{mediaId}`](https://spec.matrix.org/unstable/client-server-api/#get_matrixclientv1mediathumbnailservernamemediaid) /// (requires authentication). - /// {{% /boxes/note %}} + /// /// /// Download a thumbnail of content from the content repository. /// See the [Thumbnails](https://spec.matrix.org/unstable/client-server-api/#thumbnails) section for more information. /// - /// {{% boxes/warning %}} - /// {{% changed-in v="1.11" %}} This endpoint MAY return `404 M_NOT_FOUND` + /// **WARNING:** + /// **[Changed in `v1.11`]** This endpoint MAY return `404 M_NOT_FOUND` /// for media which exists, but is after the server froze unauthenticated /// media access. See [Client Behaviour](https://spec.matrix.org/unstable/client-server-api/#content-repo-client-behaviour) for more /// information. - /// {{% /boxes/warning %}} + /// /// /// [serverName] The server name from the `mxc://` URI (the authority component). /// diff --git a/lib/matrix_api_lite/generated/model.dart b/lib/matrix_api_lite/generated/model.dart index d31e6cba..a3208e0c 100644 --- a/lib/matrix_api_lite/generated/model.dart +++ b/lib/matrix_api_lite/generated/model.dart @@ -246,6 +246,157 @@ class GetWellknownSupportResponse { int get hashCode => Object.hash(contacts, supportPage); } +/// +@_NameSource('generated') +class GetAuthMetadataResponse { + GetAuthMetadataResponse({ + required this.authorizationEndpoint, + required this.codeChallengeMethodsSupported, + required this.grantTypesSupported, + required this.issuer, + this.promptValuesSupported, + required this.registrationEndpoint, + required this.responseModesSupported, + required this.responseTypesSupported, + required this.revocationEndpoint, + required this.tokenEndpoint, + }); + + GetAuthMetadataResponse.fromJson(Map json) + : authorizationEndpoint = + Uri.parse(json['authorization_endpoint'] as String), + codeChallengeMethodsSupported = + (json['code_challenge_methods_supported'] as List) + .map((v) => v as String) + .toList(), + grantTypesSupported = (json['grant_types_supported'] as List) + .map((v) => v as String) + .toList(), + issuer = Uri.parse(json['issuer'] as String), + promptValuesSupported = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['prompt_values_supported']), + registrationEndpoint = + Uri.parse(json['registration_endpoint'] as String), + responseModesSupported = (json['response_modes_supported'] as List) + .map((v) => v as String) + .toList(), + responseTypesSupported = (json['response_types_supported'] as List) + .map((v) => v as String) + .toList(), + revocationEndpoint = Uri.parse(json['revocation_endpoint'] as String), + tokenEndpoint = Uri.parse(json['token_endpoint'] as String); + Map toJson() { + final promptValuesSupported = this.promptValuesSupported; + return { + 'authorization_endpoint': authorizationEndpoint.toString(), + 'code_challenge_methods_supported': + codeChallengeMethodsSupported.map((v) => v).toList(), + 'grant_types_supported': grantTypesSupported.map((v) => v).toList(), + 'issuer': issuer.toString(), + if (promptValuesSupported != null) + 'prompt_values_supported': promptValuesSupported.map((v) => v).toList(), + 'registration_endpoint': registrationEndpoint.toString(), + 'response_modes_supported': responseModesSupported.map((v) => v).toList(), + 'response_types_supported': responseTypesSupported.map((v) => v).toList(), + 'revocation_endpoint': revocationEndpoint.toString(), + 'token_endpoint': tokenEndpoint.toString(), + }; + } + + /// URL of the authorization endpoint, necessary to use the authorization code + /// grant. + Uri authorizationEndpoint; + + /// List of OAuth 2.0 Proof Key for Code Exchange (PKCE) code challenge methods + /// that the server supports at the authorization endpoint. + /// + /// This array MUST contain at least the `S256` value, for improved security in + /// the authorization code grant. + List codeChallengeMethodsSupported; + + /// List of OAuth 2.0 grant type strings that the server supports at the token + /// endpoint. + /// + /// This array MUST contain at least the `authorization_code` and `refresh_token` + /// values, for clients to be able to use the authorization code grant and refresh + /// token grant, respectively. + List grantTypesSupported; + + /// The authorization server's issuer identifier, which is a URL that uses the + /// `https` scheme and has no query or fragment components. + /// + /// This is not used in the context of the Matrix specification, but is required + /// by [RFC 8414](https://datatracker.ietf.org/doc/html/rfc8414). + Uri issuer; + + /// List of OpenID Connect prompt values that the server supports at the + /// authorization endpoint. + /// + /// Only the `create` value defined in [Initiating User Registration via OpenID + /// Connect](https://openid.net/specs/openid-connect-prompt-create-1_0.html) is + /// supported, for a client to signal to the server that the user desires to + /// register a new account. + List? promptValuesSupported; + + /// URL of the client registration endpoint, necessary to perform dynamic + /// registration of a client. + Uri registrationEndpoint; + + /// List of OAuth 2.0 response mode strings that the server supports at the + /// authorization endpoint. + /// + /// This array MUST contain at least the `query` and `fragment` values, for + /// improved security in the authorization code grant. + List responseModesSupported; + + /// List of OAuth 2.0 response type strings that the server supports at the + /// authorization endpoint. + /// + /// This array MUST contain at least the `code` value, for clients to be able to + /// use the authorization code grant. + List responseTypesSupported; + + /// URL of the revocation endpoint, necessary to log out a client by invalidating + /// its access and refresh tokens. + Uri revocationEndpoint; + + /// URL of the token endpoint, necessary to use the authorization code grant and + /// the refresh token grant. + Uri tokenEndpoint; + + @dart.override + bool operator ==(Object other) => + identical(this, other) || + (other is GetAuthMetadataResponse && + other.runtimeType == runtimeType && + other.authorizationEndpoint == authorizationEndpoint && + other.codeChallengeMethodsSupported == + codeChallengeMethodsSupported && + other.grantTypesSupported == grantTypesSupported && + other.issuer == issuer && + other.promptValuesSupported == promptValuesSupported && + other.registrationEndpoint == registrationEndpoint && + other.responseModesSupported == responseModesSupported && + other.responseTypesSupported == responseTypesSupported && + other.revocationEndpoint == revocationEndpoint && + other.tokenEndpoint == tokenEndpoint); + + @dart.override + int get hashCode => Object.hash( + authorizationEndpoint, + codeChallengeMethodsSupported, + grantTypesSupported, + issuer, + promptValuesSupported, + registrationEndpoint, + responseModesSupported, + responseTypesSupported, + revocationEndpoint, + tokenEndpoint, + ); +} + /// @_NameSource('generated') class GenerateLoginTokenResponse { @@ -366,8 +517,8 @@ enum Method { /// @_NameSource('spec') -class PublicRoomsChunk { - PublicRoomsChunk({ +class PublishedRoomsChunk { + PublishedRoomsChunk({ this.avatarUrl, this.canonicalAlias, required this.guestCanJoin, @@ -380,7 +531,7 @@ class PublicRoomsChunk { required this.worldReadable, }); - PublicRoomsChunk.fromJson(Map json) + PublishedRoomsChunk.fromJson(Map json) : avatarUrl = ((v) => v != null ? Uri.parse(v as String) : null)(json['avatar_url']), canonicalAlias = @@ -441,16 +592,17 @@ class PublicRoomsChunk { /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any. String? roomType; - /// The topic of the room, if any. + /// The plain text topic of the room. Omitted if no `text/plain` mimetype + /// exists in [`m.room.topic`](https://spec.matrix.org/unstable/client-server-api/#mroomtopic). String? topic; - /// Whether the room may be viewed by guest users without joining. + /// Whether the room may be viewed by users without joining. bool worldReadable; @dart.override bool operator ==(Object other) => identical(this, other) || - (other is PublicRoomsChunk && + (other is PublishedRoomsChunk && other.runtimeType == runtimeType && other.avatarUrl == avatarUrl && other.canonicalAlias == canonicalAlias && @@ -479,51 +631,71 @@ class PublicRoomsChunk { } /// -@_NameSource('spec') -class SpaceHierarchyRoomsChunk { - SpaceHierarchyRoomsChunk({ - required this.childrenState, +@_NameSource('generated') +class GetRoomSummaryResponse$1 { + GetRoomSummaryResponse$1({ + this.allowedRoomIds, + this.encryption, this.roomType, + this.roomVersion, }); - SpaceHierarchyRoomsChunk.fromJson(Map json) - : childrenState = (json['children_state'] as List) - .map((v) => ChildrenState.fromJson(v as Map)) - .toList(), - roomType = ((v) => v != null ? v as String : null)(json['room_type']); + GetRoomSummaryResponse$1.fromJson(Map json) + : allowedRoomIds = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['allowed_room_ids']), + encryption = + ((v) => v != null ? v as String : null)(json['encryption']), + roomType = ((v) => v != null ? v as String : null)(json['room_type']), + roomVersion = + ((v) => v != null ? v as String : null)(json['room_version']); Map toJson() { + final allowedRoomIds = this.allowedRoomIds; + final encryption = this.encryption; final roomType = this.roomType; + final roomVersion = this.roomVersion; return { - 'children_state': childrenState.map((v) => v.toJson()).toList(), + if (allowedRoomIds != null) + 'allowed_room_ids': allowedRoomIds.map((v) => v).toList(), + if (encryption != null) 'encryption': encryption, if (roomType != null) 'room_type': roomType, + if (roomVersion != null) 'room_version': roomVersion, }; } - /// The [`m.space.child`](https://spec.matrix.org/unstable/client-server-api/#mspacechild) events of the space-room, represented - /// as [Stripped State Events](https://spec.matrix.org/unstable/client-server-api/#stripped-state) with an added `origin_server_ts` key. - /// - /// If the room is not a space-room, this should be empty. - List childrenState; + /// If the room is a [restricted room](https://spec.matrix.org/unstable/server-server-api/#restricted-rooms), these are the room IDs which + /// are specified by the join rules. Empty or omitted otherwise. + List? allowedRoomIds; + + /// The encryption algorithm to be used to encrypt messages sent in the + /// room. + String? encryption; /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any. String? roomType; + /// The version of the room. + String? roomVersion; + @dart.override bool operator ==(Object other) => identical(this, other) || - (other is SpaceHierarchyRoomsChunk && + (other is GetRoomSummaryResponse$1 && other.runtimeType == runtimeType && - other.childrenState == childrenState && - other.roomType == roomType); + other.allowedRoomIds == allowedRoomIds && + other.encryption == encryption && + other.roomType == roomType && + other.roomVersion == roomVersion); @dart.override - int get hashCode => Object.hash(childrenState, roomType); + int get hashCode => + Object.hash(allowedRoomIds, encryption, roomType, roomVersion); } /// -@_NameSource('rule override generated') -class SpaceRoomsChunk implements PublicRoomsChunk, SpaceHierarchyRoomsChunk { - SpaceRoomsChunk({ +@_NameSource('spec') +class RoomSummary$1 implements PublishedRoomsChunk, GetRoomSummaryResponse$1 { + RoomSummary$1({ this.avatarUrl, this.canonicalAlias, required this.guestCanJoin, @@ -534,10 +706,12 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceHierarchyRoomsChunk { this.roomType, this.topic, required this.worldReadable, - required this.childrenState, + this.allowedRoomIds, + this.encryption, + this.roomVersion, }); - SpaceRoomsChunk.fromJson(Map json) + RoomSummary$1.fromJson(Map json) : avatarUrl = ((v) => v != null ? Uri.parse(v as String) : null)(json['avatar_url']), canonicalAlias = @@ -550,9 +724,13 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceHierarchyRoomsChunk { roomType = ((v) => v != null ? v as String : null)(json['room_type']), topic = ((v) => v != null ? v as String : null)(json['topic']), worldReadable = json['world_readable'] as bool, - childrenState = (json['children_state'] as List) - .map((v) => ChildrenState.fromJson(v as Map)) - .toList(); + allowedRoomIds = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['allowed_room_ids']), + encryption = + ((v) => v != null ? v as String : null)(json['encryption']), + roomVersion = + ((v) => v != null ? v as String : null)(json['room_version']); @override Map toJson() { final avatarUrl = this.avatarUrl; @@ -561,6 +739,9 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceHierarchyRoomsChunk { final name = this.name; final roomType = this.roomType; final topic = this.topic; + final allowedRoomIds = this.allowedRoomIds; + final encryption = this.encryption; + final roomVersion = this.roomVersion; return { if (avatarUrl != null) 'avatar_url': avatarUrl.toString(), if (canonicalAlias != null) 'canonical_alias': canonicalAlias, @@ -572,7 +753,10 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceHierarchyRoomsChunk { if (roomType != null) 'room_type': roomType, if (topic != null) 'topic': topic, 'world_readable': worldReadable, - 'children_state': childrenState.map((v) => v.toJson()).toList(), + if (allowedRoomIds != null) + 'allowed_room_ids': allowedRoomIds.map((v) => v).toList(), + if (encryption != null) 'encryption': encryption, + if (roomVersion != null) 'room_version': roomVersion, }; } @@ -611,25 +795,33 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceHierarchyRoomsChunk { @override String? roomType; - /// The topic of the room, if any. + /// The plain text topic of the room. Omitted if no `text/plain` mimetype + /// exists in [`m.room.topic`](https://spec.matrix.org/unstable/client-server-api/#mroomtopic). @override String? topic; - /// Whether the room may be viewed by guest users without joining. + /// Whether the room may be viewed by users without joining. @override bool worldReadable; - /// The [`m.space.child`](https://spec.matrix.org/unstable/client-server-api/#mspacechild) events of the space-room, represented - /// as [Stripped State Events](https://spec.matrix.org/unstable/client-server-api/#stripped-state) with an added `origin_server_ts` key. - /// - /// If the room is not a space-room, this should be empty. + /// If the room is a [restricted room](https://spec.matrix.org/unstable/server-server-api/#restricted-rooms), these are the room IDs which + /// are specified by the join rules. Empty or omitted otherwise. @override - List childrenState; + List? allowedRoomIds; + + /// The encryption algorithm to be used to encrypt messages sent in the + /// room. + @override + String? encryption; + + /// The version of the room. + @override + String? roomVersion; @dart.override bool operator ==(Object other) => identical(this, other) || - (other is SpaceRoomsChunk && + (other is RoomSummary$1 && other.runtimeType == runtimeType && other.avatarUrl == avatarUrl && other.canonicalAlias == canonicalAlias && @@ -641,6 +833,707 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceHierarchyRoomsChunk { other.roomType == roomType && other.topic == topic && other.worldReadable == worldReadable && + other.allowedRoomIds == allowedRoomIds && + other.encryption == encryption && + other.roomVersion == roomVersion); + + @dart.override + int get hashCode => Object.hash( + avatarUrl, + canonicalAlias, + guestCanJoin, + joinRule, + name, + numJoinedMembers, + roomId, + roomType, + topic, + worldReadable, + allowedRoomIds, + encryption, + roomVersion, + ); +} + +/// +@_NameSource('(generated, rule override generated)') +enum Membership { + ban('ban'), + invite('invite'), + join('join'), + knock('knock'), + leave('leave'); + + final String name; + const Membership(this.name); +} + +/// +@_NameSource('generated') +class GetRoomSummaryResponse$2 { + GetRoomSummaryResponse$2({ + this.membership, + }); + + GetRoomSummaryResponse$2.fromJson(Map json) + : membership = ((v) => v != null + ? Membership.values.fromString(v as String)! + : null)(json['membership']); + Map toJson() { + final membership = this.membership; + return { + if (membership != null) 'membership': membership.name, + }; + } + + /// The membership state of the user if the user is joined to the room. Absent + /// if the API was called unauthenticated. + Membership? membership; + + @dart.override + bool operator ==(Object other) => + identical(this, other) || + (other is GetRoomSummaryResponse$2 && + other.runtimeType == runtimeType && + other.membership == membership); + + @dart.override + int get hashCode => membership.hashCode; +} + +/// A summary of the room. +@_NameSource('generated') +class GetRoomSummaryResponse$3 + implements RoomSummary$1, GetRoomSummaryResponse$2 { + GetRoomSummaryResponse$3({ + this.avatarUrl, + this.canonicalAlias, + required this.guestCanJoin, + this.joinRule, + this.name, + required this.numJoinedMembers, + required this.roomId, + this.roomType, + this.topic, + required this.worldReadable, + this.allowedRoomIds, + this.encryption, + this.roomVersion, + this.membership, + }); + + GetRoomSummaryResponse$3.fromJson(Map json) + : avatarUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']), + canonicalAlias = + ((v) => v != null ? v as String : null)(json['canonical_alias']), + guestCanJoin = json['guest_can_join'] as bool, + joinRule = ((v) => v != null ? v as String : null)(json['join_rule']), + name = ((v) => v != null ? v as String : null)(json['name']), + numJoinedMembers = json['num_joined_members'] as int, + roomId = json['room_id'] as String, + roomType = ((v) => v != null ? v as String : null)(json['room_type']), + topic = ((v) => v != null ? v as String : null)(json['topic']), + worldReadable = json['world_readable'] as bool, + allowedRoomIds = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['allowed_room_ids']), + encryption = + ((v) => v != null ? v as String : null)(json['encryption']), + roomVersion = + ((v) => v != null ? v as String : null)(json['room_version']), + membership = ((v) => v != null + ? Membership.values.fromString(v as String)! + : null)(json['membership']); + @override + Map toJson() { + final avatarUrl = this.avatarUrl; + final canonicalAlias = this.canonicalAlias; + final joinRule = this.joinRule; + final name = this.name; + final roomType = this.roomType; + final topic = this.topic; + final allowedRoomIds = this.allowedRoomIds; + final encryption = this.encryption; + final roomVersion = this.roomVersion; + final membership = this.membership; + return { + if (avatarUrl != null) 'avatar_url': avatarUrl.toString(), + if (canonicalAlias != null) 'canonical_alias': canonicalAlias, + 'guest_can_join': guestCanJoin, + if (joinRule != null) 'join_rule': joinRule, + if (name != null) 'name': name, + 'num_joined_members': numJoinedMembers, + 'room_id': roomId, + if (roomType != null) 'room_type': roomType, + if (topic != null) 'topic': topic, + 'world_readable': worldReadable, + if (allowedRoomIds != null) + 'allowed_room_ids': allowedRoomIds.map((v) => v).toList(), + if (encryption != null) 'encryption': encryption, + if (roomVersion != null) 'room_version': roomVersion, + if (membership != null) 'membership': membership.name, + }; + } + + /// The URL for the room's avatar, if one is set. + @override + Uri? avatarUrl; + + /// The canonical alias of the room, if any. + @override + String? canonicalAlias; + + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. + @override + bool guestCanJoin; + + /// The room's join rule. When not present, the room is assumed to + /// be `public`. + @override + String? joinRule; + + /// The name of the room, if any. + @override + String? name; + + /// The number of members joined to the room. + @override + int numJoinedMembers; + + /// The ID of the room. + @override + String roomId; + + /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any. + @override + String? roomType; + + /// The plain text topic of the room. Omitted if no `text/plain` mimetype + /// exists in [`m.room.topic`](https://spec.matrix.org/unstable/client-server-api/#mroomtopic). + @override + String? topic; + + /// Whether the room may be viewed by users without joining. + @override + bool worldReadable; + + /// If the room is a [restricted room](https://spec.matrix.org/unstable/server-server-api/#restricted-rooms), these are the room IDs which + /// are specified by the join rules. Empty or omitted otherwise. + @override + List? allowedRoomIds; + + /// The encryption algorithm to be used to encrypt messages sent in the + /// room. + @override + String? encryption; + + /// The version of the room. + @override + String? roomVersion; + + /// The membership state of the user if the user is joined to the room. Absent + /// if the API was called unauthenticated. + @override + Membership? membership; + + @dart.override + bool operator ==(Object other) => + identical(this, other) || + (other is GetRoomSummaryResponse$3 && + other.runtimeType == runtimeType && + other.avatarUrl == avatarUrl && + other.canonicalAlias == canonicalAlias && + other.guestCanJoin == guestCanJoin && + other.joinRule == joinRule && + other.name == name && + other.numJoinedMembers == numJoinedMembers && + other.roomId == roomId && + other.roomType == roomType && + other.topic == topic && + other.worldReadable == worldReadable && + other.allowedRoomIds == allowedRoomIds && + other.encryption == encryption && + other.roomVersion == roomVersion && + other.membership == membership); + + @dart.override + int get hashCode => Object.hash( + avatarUrl, + canonicalAlias, + guestCanJoin, + joinRule, + name, + numJoinedMembers, + roomId, + roomType, + topic, + worldReadable, + allowedRoomIds, + encryption, + roomVersion, + membership, + ); +} + +/// +@_NameSource('rule override generated') +class SpaceRoomsChunk$1 { + SpaceRoomsChunk$1({ + this.allowedRoomIds, + this.encryption, + this.roomType, + this.roomVersion, + }); + + SpaceRoomsChunk$1.fromJson(Map json) + : allowedRoomIds = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['allowed_room_ids']), + encryption = + ((v) => v != null ? v as String : null)(json['encryption']), + roomType = ((v) => v != null ? v as String : null)(json['room_type']), + roomVersion = + ((v) => v != null ? v as String : null)(json['room_version']); + Map toJson() { + final allowedRoomIds = this.allowedRoomIds; + final encryption = this.encryption; + final roomType = this.roomType; + final roomVersion = this.roomVersion; + return { + if (allowedRoomIds != null) + 'allowed_room_ids': allowedRoomIds.map((v) => v).toList(), + if (encryption != null) 'encryption': encryption, + if (roomType != null) 'room_type': roomType, + if (roomVersion != null) 'room_version': roomVersion, + }; + } + + /// If the room is a [restricted room](https://spec.matrix.org/unstable/server-server-api/#restricted-rooms), these are the room IDs which + /// are specified by the join rules. Empty or omitted otherwise. + List? allowedRoomIds; + + /// The encryption algorithm to be used to encrypt messages sent in the + /// room. + String? encryption; + + /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any. + String? roomType; + + /// The version of the room. + String? roomVersion; + + @dart.override + bool operator ==(Object other) => + identical(this, other) || + (other is SpaceRoomsChunk$1 && + other.runtimeType == runtimeType && + other.allowedRoomIds == allowedRoomIds && + other.encryption == encryption && + other.roomType == roomType && + other.roomVersion == roomVersion); + + @dart.override + int get hashCode => + Object.hash(allowedRoomIds, encryption, roomType, roomVersion); +} + +/// +@_NameSource('spec') +class RoomSummary$2 implements PublishedRoomsChunk, SpaceRoomsChunk$1 { + RoomSummary$2({ + this.avatarUrl, + this.canonicalAlias, + required this.guestCanJoin, + this.joinRule, + this.name, + required this.numJoinedMembers, + required this.roomId, + this.roomType, + this.topic, + required this.worldReadable, + this.allowedRoomIds, + this.encryption, + this.roomVersion, + }); + + RoomSummary$2.fromJson(Map json) + : avatarUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']), + canonicalAlias = + ((v) => v != null ? v as String : null)(json['canonical_alias']), + guestCanJoin = json['guest_can_join'] as bool, + joinRule = ((v) => v != null ? v as String : null)(json['join_rule']), + name = ((v) => v != null ? v as String : null)(json['name']), + numJoinedMembers = json['num_joined_members'] as int, + roomId = json['room_id'] as String, + roomType = ((v) => v != null ? v as String : null)(json['room_type']), + topic = ((v) => v != null ? v as String : null)(json['topic']), + worldReadable = json['world_readable'] as bool, + allowedRoomIds = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['allowed_room_ids']), + encryption = + ((v) => v != null ? v as String : null)(json['encryption']), + roomVersion = + ((v) => v != null ? v as String : null)(json['room_version']); + @override + Map toJson() { + final avatarUrl = this.avatarUrl; + final canonicalAlias = this.canonicalAlias; + final joinRule = this.joinRule; + final name = this.name; + final roomType = this.roomType; + final topic = this.topic; + final allowedRoomIds = this.allowedRoomIds; + final encryption = this.encryption; + final roomVersion = this.roomVersion; + return { + if (avatarUrl != null) 'avatar_url': avatarUrl.toString(), + if (canonicalAlias != null) 'canonical_alias': canonicalAlias, + 'guest_can_join': guestCanJoin, + if (joinRule != null) 'join_rule': joinRule, + if (name != null) 'name': name, + 'num_joined_members': numJoinedMembers, + 'room_id': roomId, + if (roomType != null) 'room_type': roomType, + if (topic != null) 'topic': topic, + 'world_readable': worldReadable, + if (allowedRoomIds != null) + 'allowed_room_ids': allowedRoomIds.map((v) => v).toList(), + if (encryption != null) 'encryption': encryption, + if (roomVersion != null) 'room_version': roomVersion, + }; + } + + /// The URL for the room's avatar, if one is set. + @override + Uri? avatarUrl; + + /// The canonical alias of the room, if any. + @override + String? canonicalAlias; + + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. + @override + bool guestCanJoin; + + /// The room's join rule. When not present, the room is assumed to + /// be `public`. + @override + String? joinRule; + + /// The name of the room, if any. + @override + String? name; + + /// The number of members joined to the room. + @override + int numJoinedMembers; + + /// The ID of the room. + @override + String roomId; + + /// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any. + @override + String? roomType; + + /// The plain text topic of the room. Omitted if no `text/plain` mimetype + /// exists in [`m.room.topic`](https://spec.matrix.org/unstable/client-server-api/#mroomtopic). + @override + String? topic; + + /// Whether the room may be viewed by users without joining. + @override + bool worldReadable; + + /// If the room is a [restricted room](https://spec.matrix.org/unstable/server-server-api/#restricted-rooms), these are the room IDs which + /// are specified by the join rules. Empty or omitted otherwise. + @override + List? allowedRoomIds; + + /// The encryption algorithm to be used to encrypt messages sent in the + /// room. + @override + String? encryption; + + /// The version of the room. + @override + String? roomVersion; + + @dart.override + bool operator ==(Object other) => + identical(this, other) || + (other is RoomSummary$2 && + other.runtimeType == runtimeType && + other.avatarUrl == avatarUrl && + other.canonicalAlias == canonicalAlias && + other.guestCanJoin == guestCanJoin && + other.joinRule == joinRule && + other.name == name && + other.numJoinedMembers == numJoinedMembers && + other.roomId == roomId && + other.roomType == roomType && + other.topic == topic && + other.worldReadable == worldReadable && + other.allowedRoomIds == allowedRoomIds && + other.encryption == encryption && + other.roomVersion == roomVersion); + + @dart.override + int get hashCode => Object.hash( + avatarUrl, + canonicalAlias, + guestCanJoin, + joinRule, + name, + numJoinedMembers, + roomId, + roomType, + topic, + worldReadable, + allowedRoomIds, + encryption, + roomVersion, + ); +} + +/// +@_NameSource('spec') +class SpaceHierarchyRoomsChunk { + SpaceHierarchyRoomsChunk({ + this.allowedRoomIds, + required this.childrenState, + this.encryption, + this.roomType, + this.roomVersion, + }); + + SpaceHierarchyRoomsChunk.fromJson(Map json) + : allowedRoomIds = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['allowed_room_ids']), + childrenState = (json['children_state'] as List) + .map((v) => ChildrenState.fromJson(v as Map)) + .toList(), + encryption = + ((v) => v != null ? v as String : null)(json['encryption']), + roomType = ((v) => v != null ? v as String : null)(json['room_type']), + roomVersion = + ((v) => v != null ? v as String : null)(json['room_version']); + Map toJson() { + final allowedRoomIds = this.allowedRoomIds; + final encryption = this.encryption; + final roomType = this.roomType; + final roomVersion = this.roomVersion; + return { + if (allowedRoomIds != null) + 'allowed_room_ids': allowedRoomIds.map((v) => v).toList(), + 'children_state': childrenState.map((v) => v.toJson()).toList(), + if (encryption != null) 'encryption': encryption, + if (roomType != null) 'room_type': roomType, + if (roomVersion != null) 'room_version': roomVersion, + }; + } + + /// + List? allowedRoomIds; + + /// The [`m.space.child`](https://spec.matrix.org/unstable/client-server-api/#mspacechild) events of the space-room, represented + /// as [Stripped State Events](https://spec.matrix.org/unstable/client-server-api/#stripped-state) with an added `origin_server_ts` key. + /// + /// If the room is not a space-room, this should be empty. + List childrenState; + + /// + String? encryption; + + /// + String? roomType; + + /// + String? roomVersion; + + @dart.override + bool operator ==(Object other) => + identical(this, other) || + (other is SpaceHierarchyRoomsChunk && + other.runtimeType == runtimeType && + other.allowedRoomIds == allowedRoomIds && + other.childrenState == childrenState && + other.encryption == encryption && + other.roomType == roomType && + other.roomVersion == roomVersion); + + @dart.override + int get hashCode => Object.hash( + allowedRoomIds, + childrenState, + encryption, + roomType, + roomVersion, + ); +} + +/// +@_NameSource('rule override generated') +class SpaceRoomsChunk$2 implements RoomSummary$2, SpaceHierarchyRoomsChunk { + SpaceRoomsChunk$2({ + this.avatarUrl, + this.canonicalAlias, + required this.guestCanJoin, + this.joinRule, + this.name, + required this.numJoinedMembers, + required this.roomId, + this.roomType, + this.topic, + required this.worldReadable, + this.allowedRoomIds, + this.encryption, + this.roomVersion, + required this.childrenState, + }); + + SpaceRoomsChunk$2.fromJson(Map json) + : avatarUrl = ((v) => + v != null ? Uri.parse(v as String) : null)(json['avatar_url']), + canonicalAlias = + ((v) => v != null ? v as String : null)(json['canonical_alias']), + guestCanJoin = json['guest_can_join'] as bool, + joinRule = ((v) => v != null ? v as String : null)(json['join_rule']), + name = ((v) => v != null ? v as String : null)(json['name']), + numJoinedMembers = json['num_joined_members'] as int, + roomId = json['room_id'] as String, + roomType = ((v) => v != null ? v as String : null)(json['room_type']), + topic = ((v) => v != null ? v as String : null)(json['topic']), + worldReadable = json['world_readable'] as bool, + allowedRoomIds = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['allowed_room_ids']), + encryption = + ((v) => v != null ? v as String : null)(json['encryption']), + roomVersion = + ((v) => v != null ? v as String : null)(json['room_version']), + childrenState = (json['children_state'] as List) + .map((v) => ChildrenState.fromJson(v as Map)) + .toList(); + @override + Map toJson() { + final avatarUrl = this.avatarUrl; + final canonicalAlias = this.canonicalAlias; + final joinRule = this.joinRule; + final name = this.name; + final roomType = this.roomType; + final topic = this.topic; + final allowedRoomIds = this.allowedRoomIds; + final encryption = this.encryption; + final roomVersion = this.roomVersion; + return { + if (avatarUrl != null) 'avatar_url': avatarUrl.toString(), + if (canonicalAlias != null) 'canonical_alias': canonicalAlias, + 'guest_can_join': guestCanJoin, + if (joinRule != null) 'join_rule': joinRule, + if (name != null) 'name': name, + 'num_joined_members': numJoinedMembers, + 'room_id': roomId, + if (roomType != null) 'room_type': roomType, + if (topic != null) 'topic': topic, + 'world_readable': worldReadable, + if (allowedRoomIds != null) + 'allowed_room_ids': allowedRoomIds.map((v) => v).toList(), + if (encryption != null) 'encryption': encryption, + if (roomVersion != null) 'room_version': roomVersion, + 'children_state': childrenState.map((v) => v.toJson()).toList(), + }; + } + + /// The URL for the room's avatar, if one is set. + @override + Uri? avatarUrl; + + /// The canonical alias of the room, if any. + @override + String? canonicalAlias; + + /// Whether guest users may join the room and participate in it. + /// If they can, they will be subject to ordinary power level + /// rules like any other user. + @override + bool guestCanJoin; + + /// The room's join rule. When not present, the room is assumed to + /// be `public`. + @override + String? joinRule; + + /// The name of the room, if any. + @override + String? name; + + /// The number of members joined to the room. + @override + int numJoinedMembers; + + /// The ID of the room. + @override + String roomId; + + /// + @override + String? roomType; + + /// The plain text topic of the room. Omitted if no `text/plain` mimetype + /// exists in [`m.room.topic`](https://spec.matrix.org/unstable/client-server-api/#mroomtopic). + @override + String? topic; + + /// Whether the room may be viewed by users without joining. + @override + bool worldReadable; + + /// + @override + List? allowedRoomIds; + + /// + @override + String? encryption; + + /// + @override + String? roomVersion; + + /// The [`m.space.child`](https://spec.matrix.org/unstable/client-server-api/#mspacechild) events of the space-room, represented + /// as [Stripped State Events](https://spec.matrix.org/unstable/client-server-api/#stripped-state) with an added `origin_server_ts` key. + /// + /// If the room is not a space-room, this should be empty. + @override + List childrenState; + + @dart.override + bool operator ==(Object other) => + identical(this, other) || + (other is SpaceRoomsChunk$2 && + other.runtimeType == runtimeType && + other.avatarUrl == avatarUrl && + other.canonicalAlias == canonicalAlias && + other.guestCanJoin == guestCanJoin && + other.joinRule == joinRule && + other.name == name && + other.numJoinedMembers == numJoinedMembers && + other.roomId == roomId && + other.roomType == roomType && + other.topic == topic && + other.worldReadable == worldReadable && + other.allowedRoomIds == allowedRoomIds && + other.encryption == encryption && + other.roomVersion == roomVersion && other.childrenState == childrenState); @dart.override @@ -655,6 +1548,9 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceHierarchyRoomsChunk { roomType, topic, worldReadable, + allowedRoomIds, + encryption, + roomVersion, childrenState, ); } @@ -670,7 +1566,7 @@ class GetSpaceHierarchyResponse { GetSpaceHierarchyResponse.fromJson(Map json) : nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), rooms = (json['rooms'] as List) - .map((v) => SpaceRoomsChunk.fromJson(v as Map)) + .map((v) => SpaceRoomsChunk$2.fromJson(v as Map)) .toList(); Map toJson() { final nextBatch = this.nextBatch; @@ -695,7 +1591,7 @@ class GetSpaceHierarchyResponse { /// * The room's join rules are set to [`restricted`](#restricted-rooms), provided the user meets one of the specified conditions. /// * The room is "knockable" (the room's join rules are set to `knock`, or `knock_restricted`, in a room version that supports those settings). /// * The room's [`m.room.history_visibility`](#room-history-visibility) is set to `world_readable`. - List rooms; + List rooms; @dart.override bool operator ==(Object other) => @@ -1404,6 +2300,65 @@ class BooleanCapability { int get hashCode => enabled.hashCode; } +/// +@_NameSource('spec') +class ProfileFieldsCapability { + ProfileFieldsCapability({ + this.allowed, + this.disallowed, + required this.enabled, + }); + + ProfileFieldsCapability.fromJson(Map json) + : allowed = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['allowed']), + disallowed = ((v) => v != null + ? (v as List).map((v) => v as String).toList() + : null)(json['disallowed']), + enabled = json['enabled'] as bool; + Map toJson() { + final allowed = this.allowed; + final disallowed = this.disallowed; + return { + if (allowed != null) 'allowed': allowed.map((v) => v).toList(), + if (disallowed != null) 'disallowed': disallowed.map((v) => v).toList(), + 'enabled': enabled, + }; + } + + /// If present, a list of profile fields that clients are allowed to create, modify or delete, + /// provided `enabled` is `true`; no other profile fields may be changed. + /// + /// If absent, clients may set all profile fields except those forbidden by the `disallowed` + /// list, where present. + /// + List? allowed; + + /// This property has no meaning if `allowed` is also specified. + /// + /// Otherwise, if present, a list of profile fields that clients are _not_ allowed to create, modify or delete. + /// Provided `enabled` is `true`, clients MAY assume that they can set any profile field which is not + /// included in this list. + /// + List? disallowed; + + /// `true` if the user can create, update or delete any profile fields, `false` otherwise. + bool enabled; + + @dart.override + bool operator ==(Object other) => + identical(this, other) || + (other is ProfileFieldsCapability && + other.runtimeType == runtimeType && + other.allowed == allowed && + other.disallowed == disallowed && + other.enabled == enabled); + + @dart.override + int get hashCode => Object.hash(allowed, disallowed, enabled); +} + /// The stability of the room version. @_NameSource('rule override generated') enum RoomVersionAvailable { @@ -1458,6 +2413,7 @@ class Capabilities { this.m3pidChanges, this.mChangePassword, this.mGetLoginToken, + this.mProfileFields, this.mRoomVersions, this.mSetAvatarUrl, this.mSetDisplayname, @@ -1474,6 +2430,9 @@ class Capabilities { mGetLoginToken = ((v) => v != null ? BooleanCapability.fromJson(v as Map) : null)(json['m.get_login_token']), + mProfileFields = ((v) => v != null + ? ProfileFieldsCapability.fromJson(v as Map) + : null)(json['m.profile_fields']), mRoomVersions = ((v) => v != null ? RoomVersionsCapability.fromJson(v as Map) : null)(json['m.room_versions']), @@ -1490,6 +2449,7 @@ class Capabilities { 'm.3pid_changes', 'm.change_password', 'm.get_login_token', + 'm.profile_fields', 'm.room_versions', 'm.set_avatar_url', 'm.set_displayname', @@ -1501,6 +2461,7 @@ class Capabilities { final m3pidChanges = this.m3pidChanges; final mChangePassword = this.mChangePassword; final mGetLoginToken = this.mGetLoginToken; + final mProfileFields = this.mProfileFields; final mRoomVersions = this.mRoomVersions; final mSetAvatarUrl = this.mSetAvatarUrl; final mSetDisplayname = this.mSetDisplayname; @@ -1510,6 +2471,7 @@ class Capabilities { if (mChangePassword != null) 'm.change_password': mChangePassword.toJson(), if (mGetLoginToken != null) 'm.get_login_token': mGetLoginToken.toJson(), + if (mProfileFields != null) 'm.profile_fields': mProfileFields.toJson(), if (mRoomVersions != null) 'm.room_versions': mRoomVersions.toJson(), if (mSetAvatarUrl != null) 'm.set_avatar_url': mSetAvatarUrl.toJson(), if (mSetDisplayname != null) @@ -1526,13 +2488,28 @@ class Capabilities { /// Capability to indicate if the user can generate tokens to log further clients into their account. BooleanCapability? mGetLoginToken; + /// Capability to indicate if the user can set or modify extended profile fields via [`PUT /_matrix/client/v3/profile/{userId}/{keyName}`](https://spec.matrix.org/unstable/client-server-api/#put_matrixclientv3profileuseridkeyname). If absent, clients SHOULD assume custom profile fields are supported, provided the homeserver advertises a specification version that includes `m.profile_fields` in the [`/versions`](https://spec.matrix.org/unstable/client-server-api/#get_matrixclientversions) response. + ProfileFieldsCapability? mProfileFields; + /// The room versions the server supports. RoomVersionsCapability? mRoomVersions; - /// Capability to indicate if the user can change their avatar. + /// **Deprecated:** Capability to indicate if the user can change their avatar. + /// Refer to `m.profile_fields` for extended profile management. + /// + /// For backwards compatibility, servers that directly or indirectly include the + /// `avatar_url` profile field in the `m.profile_fields` capability MUST also + /// set this capability accordingly. + /// BooleanCapability? mSetAvatarUrl; - /// Capability to indicate if the user can change their display name. + /// **Deprecated:** Capability to indicate if the user can change their display name. + /// Refer to `m.profile_fields` for extended profile management. + /// + /// For backwards compatibility, servers that directly or indirectly include the + /// `displayname` profile field in the `m.profile_fields` capability MUST also + /// set this capability accordingly. + /// BooleanCapability? mSetDisplayname; Map additionalProperties; @@ -1545,6 +2522,7 @@ class Capabilities { other.m3pidChanges == m3pidChanges && other.mChangePassword == mChangePassword && other.mGetLoginToken == mGetLoginToken && + other.mProfileFields == mProfileFields && other.mRoomVersions == mRoomVersions && other.mSetAvatarUrl == mSetAvatarUrl && other.mSetDisplayname == mSetDisplayname); @@ -1554,6 +2532,7 @@ class Capabilities { m3pidChanges, mChangePassword, mGetLoginToken, + mProfileFields, mRoomVersions, mSetAvatarUrl, mSetDisplayname, @@ -2516,19 +3495,35 @@ class ProfileInformation { ProfileInformation({ this.avatarUrl, this.displayname, + this.mTz, + this.additionalProperties = const {}, }); ProfileInformation.fromJson(Map json) - : avatarUrl = ((v) => - v != null ? Uri.parse(v as String) : null)(json['avatar_url']), + : avatarUrl = ((v) => v != null + ? ((v as String).startsWith('mxc://') + ? Uri.parse(v) + : throw Exception('Uri not an mxc URI')) + : null)(json['avatar_url']), displayname = - ((v) => v != null ? v as String : null)(json['displayname']); + ((v) => v != null ? v as String : null)(json['displayname']), + mTz = ((v) => v != null ? v as String : null)(json['m.tz']), + additionalProperties = Map.fromEntries( + json.entries + .where( + (e) => !['avatar_url', 'displayname', 'm.tz'].contains(e.key), + ) + .map((e) => MapEntry(e.key, e.value)), + ); Map toJson() { final avatarUrl = this.avatarUrl; final displayname = this.displayname; + final mTz = this.mTz; return { + ...additionalProperties, if (avatarUrl != null) 'avatar_url': avatarUrl.toString(), if (displayname != null) 'displayname': displayname, + if (mTz != null) 'm.tz': mTz, }; } @@ -2538,19 +3533,25 @@ class ProfileInformation { /// The user's display name if they have set one, otherwise not present. String? displayname; + /// The user's time zone. + String? mTz; + + Map additionalProperties; + @dart.override bool operator ==(Object other) => identical(this, other) || (other is ProfileInformation && other.runtimeType == runtimeType && other.avatarUrl == avatarUrl && - other.displayname == displayname); + other.displayname == displayname && + other.mTz == mTz); @dart.override - int get hashCode => Object.hash(avatarUrl, displayname); + int get hashCode => Object.hash(avatarUrl, displayname, mTz); } -/// A list of the rooms on the server. +/// A list of the published rooms on the server. @_NameSource('generated') class GetPublicRoomsResponse { GetPublicRoomsResponse({ @@ -2562,7 +3563,7 @@ class GetPublicRoomsResponse { GetPublicRoomsResponse.fromJson(Map json) : chunk = (json['chunk'] as List) - .map((v) => PublicRoomsChunk.fromJson(v as Map)) + .map((v) => PublishedRoomsChunk.fromJson(v as Map)) .toList(), nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']), @@ -2581,8 +3582,8 @@ class GetPublicRoomsResponse { }; } - /// A paginated chunk of public rooms. - List chunk; + /// A paginated chunk of published rooms. + List chunk; /// A pagination token for the response. The absence of this token /// means there are no more results to fetch and the client should @@ -2594,7 +3595,7 @@ class GetPublicRoomsResponse { /// batch, i.e. this is the first batch. String? prevBatch; - /// An estimate on the total number of public rooms, if the + /// An estimate on the total number of published rooms, if the /// server has an estimate. int? totalRoomCountEstimate; @@ -2660,7 +3661,7 @@ class PublicRoomQueryFilter { int get hashCode => Object.hash(genericSearchTerm, roomTypes); } -/// A list of the rooms on the server. +/// A list of the published rooms on the server. @_NameSource('generated') class QueryPublicRoomsResponse { QueryPublicRoomsResponse({ @@ -2672,7 +3673,7 @@ class QueryPublicRoomsResponse { QueryPublicRoomsResponse.fromJson(Map json) : chunk = (json['chunk'] as List) - .map((v) => PublicRoomsChunk.fromJson(v as Map)) + .map((v) => PublishedRoomsChunk.fromJson(v as Map)) .toList(), nextBatch = ((v) => v != null ? v as String : null)(json['next_batch']), prevBatch = ((v) => v != null ? v as String : null)(json['prev_batch']), @@ -2691,8 +3692,8 @@ class QueryPublicRoomsResponse { }; } - /// A paginated chunk of public rooms. - List chunk; + /// A paginated chunk of published rooms. + List chunk; /// A pagination token for the response. The absence of this token /// means there are no more results to fetch and the client should @@ -2704,7 +3705,7 @@ class QueryPublicRoomsResponse { /// batch, i.e. this is the first batch. String? prevBatch; - /// An estimate on the total number of public rooms, if the + /// An estimate on the total number of published rooms, if the /// server has an estimate. int? totalRoomCountEstimate; @@ -3813,19 +4814,6 @@ class RoomMember { int get hashCode => Object.hash(avatarUrl, displayName); } -/// -@_NameSource('(generated, rule override generated)') -enum Membership { - ban('ban'), - invite('invite'), - join('join'), - knock('knock'), - leave('leave'); - - final String name; - const Membership(this.name); -} - /// A list of messages with a new token to request more. @_NameSource('generated') class GetRoomEventsResponse { @@ -3916,6 +4904,16 @@ enum ReceiptType { const ReceiptType(this.name); } +/// +@_NameSource('generated') +enum Format { + content('content'), + event('event'); + + final String name; + const Format(this.name); +} + /// @_NameSource('spec') class IncludeEventContext { @@ -5238,22 +6236,16 @@ class Instances$2 implements ProtocolInstance, Instances$1 { @_NameSource('generated') class GetProtocolMetadataResponse$1 { GetProtocolMetadataResponse$1({ - this.instances, + required this.instances, }); GetProtocolMetadataResponse$1.fromJson(Map json) - : instances = ((v) => v != null - ? (v as List) - .map((v) => Instances$2.fromJson(v as Map)) - .toList() - : null)(json['instances']); - Map toJson() { - final instances = this.instances; - return { - if (instances != null) + : instances = (json['instances'] as List) + .map((v) => Instances$2.fromJson(v as Map)) + .toList(); + Map toJson() => { 'instances': instances.map((v) => v.toJson()).toList(), - }; - } + }; /// A list of objects representing independent instances of configuration. /// For example, multiple networks on IRC if multiple are provided by the @@ -5263,7 +6255,7 @@ class GetProtocolMetadataResponse$1 { /// [`GET /_matrix/app/v1/thirdparty/protocol/{protocol}`](https://spec.matrix.org/unstable/application-service-api/#get_matrixappv1thirdpartyprotocolprotocol) /// to include an `instance_id` to serve as a unique identifier for each /// instance on the homeserver. - List? instances; + List instances; @dart.override bool operator ==(Object other) => @@ -5285,7 +6277,7 @@ class GetProtocolMetadataResponse$2 required this.icon, required this.locationFields, required this.userFields, - this.instances, + required this.instances, }); GetProtocolMetadataResponse$2.fromJson(Map json) @@ -5297,23 +6289,17 @@ class GetProtocolMetadataResponse$2 (json['location_fields'] as List).map((v) => v as String).toList(), userFields = (json['user_fields'] as List).map((v) => v as String).toList(), - instances = ((v) => v != null - ? (v as List) - .map((v) => Instances$2.fromJson(v as Map)) - .toList() - : null)(json['instances']); + instances = (json['instances'] as List) + .map((v) => Instances$2.fromJson(v as Map)) + .toList(); @override - Map toJson() { - final instances = this.instances; - return { - 'field_types': fieldTypes.map((k, v) => MapEntry(k, v.toJson())), - 'icon': icon, - 'location_fields': locationFields.map((v) => v).toList(), - 'user_fields': userFields.map((v) => v).toList(), - if (instances != null) + Map toJson() => { + 'field_types': fieldTypes.map((k, v) => MapEntry(k, v.toJson())), + 'icon': icon, + 'location_fields': locationFields.map((v) => v).toList(), + 'user_fields': userFields.map((v) => v).toList(), 'instances': instances.map((v) => v.toJson()).toList(), - }; - } + }; /// The type definitions for the fields defined in `user_fields` and /// `location_fields`. Each entry in those arrays MUST have an entry here. @@ -5350,7 +6336,7 @@ class GetProtocolMetadataResponse$2 /// to include an `instance_id` to serve as a unique identifier for each /// instance on the homeserver. @override - List? instances; + List instances; @dart.override bool operator ==(Object other) => @@ -5372,22 +6358,16 @@ class GetProtocolMetadataResponse$2 @_NameSource('generated') class GetProtocolsResponse$1 { GetProtocolsResponse$1({ - this.instances, + required this.instances, }); GetProtocolsResponse$1.fromJson(Map json) - : instances = ((v) => v != null - ? (v as List) - .map((v) => Instances$2.fromJson(v as Map)) - .toList() - : null)(json['instances']); - Map toJson() { - final instances = this.instances; - return { - if (instances != null) + : instances = (json['instances'] as List) + .map((v) => Instances$2.fromJson(v as Map)) + .toList(); + Map toJson() => { 'instances': instances.map((v) => v.toJson()).toList(), - }; - } + }; /// A list of objects representing independent instances of configuration. /// For example, multiple networks on IRC if multiple are provided by the @@ -5397,7 +6377,7 @@ class GetProtocolsResponse$1 { /// [`GET /_matrix/app/v1/thirdparty/protocol/{protocol}`](https://spec.matrix.org/unstable/application-service-api/#get_matrixappv1thirdpartyprotocolprotocol) /// to include an `instance_id` to serve as a unique identifier for each /// instance on the homeserver. - List? instances; + List instances; @dart.override bool operator ==(Object other) => @@ -5418,7 +6398,7 @@ class GetProtocolsResponse$2 implements Protocol, GetProtocolsResponse$1 { required this.icon, required this.locationFields, required this.userFields, - this.instances, + required this.instances, }); GetProtocolsResponse$2.fromJson(Map json) @@ -5430,23 +6410,17 @@ class GetProtocolsResponse$2 implements Protocol, GetProtocolsResponse$1 { (json['location_fields'] as List).map((v) => v as String).toList(), userFields = (json['user_fields'] as List).map((v) => v as String).toList(), - instances = ((v) => v != null - ? (v as List) - .map((v) => Instances$2.fromJson(v as Map)) - .toList() - : null)(json['instances']); + instances = (json['instances'] as List) + .map((v) => Instances$2.fromJson(v as Map)) + .toList(); @override - Map toJson() { - final instances = this.instances; - return { - 'field_types': fieldTypes.map((k, v) => MapEntry(k, v.toJson())), - 'icon': icon, - 'location_fields': locationFields.map((v) => v).toList(), - 'user_fields': userFields.map((v) => v).toList(), - if (instances != null) + Map toJson() => { + 'field_types': fieldTypes.map((k, v) => MapEntry(k, v.toJson())), + 'icon': icon, + 'location_fields': locationFields.map((v) => v).toList(), + 'user_fields': userFields.map((v) => v).toList(), 'instances': instances.map((v) => v.toJson()).toList(), - }; - } + }; /// The type definitions for the fields defined in `user_fields` and /// `location_fields`. Each entry in those arrays MUST have an entry here. @@ -5483,7 +6457,7 @@ class GetProtocolsResponse$2 implements Protocol, GetProtocolsResponse$1 { /// to include an `instance_id` to serve as a unique identifier for each /// instance on the homeserver. @override - List? instances; + List instances; @dart.override bool operator ==(Object other) => diff --git a/lib/src/client.dart b/lib/src/client.dart index cea838e5..b8226386 100644 --- a/lib/src/client.dart +++ b/lib/src/client.dart @@ -1611,14 +1611,23 @@ class Client extends MatrixApi { // We send an empty String to remove the avatar. Sending Null **should** // work but it doesn't with Synapse. See: // https://gitlab.com/famedly/company/frontend/famedlysdk/-/issues/254 - return setAvatarUrl(userID!, Uri.parse('')); + await setProfileField( + userID!, + 'avatar_url', + {'avatar_url': Uri.parse('')}, + ); + return; } final uploadResp = await uploadContent( file.bytes, filename: file.name, contentType: file.mimeType, ); - await setAvatarUrl(userID!, uploadResp); + await setProfileField( + userID!, + 'avatar_url', + {'avatar_url': uploadResp.toString()}, + ); return; }