feat: v1.12 spec endpoints support (BREAKING CHANGE)

This commit is contained in:
td 2024-10-21 13:58:33 +02:00
parent 7e8496a70f
commit 7605b1de31
No known key found for this signature in database
GPG Key ID: 62A30523D4D6CE28
4 changed files with 227 additions and 73 deletions

View File

@ -119,7 +119,7 @@ class Api {
/// ///
/// Clients, both authenticated and unauthenticated, might wish to hide user interface which exposes /// Clients, both authenticated and unauthenticated, might wish to hide user interface which exposes
/// this feature if the server is not offering it. Authenticated clients can check for support on /// this feature if the server is not offering it. Authenticated clients can check for support on
/// a per-user basis with the `m.get_login_token` [capability](https://spec.matrix.org/unstable/client-server-api/#capabilities-negotiation), /// a per-user basis with the [`m.get_login_token`](https://spec.matrix.org/unstable/client-server-api/#mget_login_token-capability) capability,
/// while unauthenticated clients can detect server support by looking for an `m.login.token` login /// while unauthenticated clients can detect server support by looking for an `m.login.token` login
/// flow with `get_login_token: true` on [`GET /login`](https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3login). /// flow with `get_login_token: true` on [`GET /login`](https://spec.matrix.org/unstable/client-server-api/#post_matrixclientv3login).
/// ///
@ -1982,6 +1982,9 @@ class Api {
/// [serverName] The servers to attempt to join the room through. One of the servers /// [serverName] The servers to attempt to join the room through. One of the servers
/// must be participating in the room. /// must be participating in the room.
/// ///
/// [via] The servers to attempt to join the room through. One of the servers
/// must be participating in the room.
///
/// [reason] Optional reason to be included as the `reason` on the subsequent /// [reason] Optional reason to be included as the `reason` on the subsequent
/// membership event. /// membership event.
/// ///
@ -1993,12 +1996,14 @@ class Api {
/// The joined room ID. /// The joined room ID.
Future<String> joinRoom(String roomIdOrAlias, Future<String> joinRoom(String roomIdOrAlias,
{List<String>? serverName, {List<String>? serverName,
List<String>? via,
String? reason, String? reason,
ThirdPartySigned? thirdPartySigned}) async { ThirdPartySigned? thirdPartySigned}) async {
final requestUri = Uri( final requestUri = Uri(
path: '_matrix/client/v3/join/${Uri.encodeComponent(roomIdOrAlias)}', path: '_matrix/client/v3/join/${Uri.encodeComponent(roomIdOrAlias)}',
queryParameters: { queryParameters: {
if (serverName != null) 'server_name': serverName, if (serverName != null) 'server_name': serverName,
if (via != null) 'via': via,
}); });
final request = Request('POST', baseUri!.resolveUri(requestUri)); final request = Request('POST', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}'; request.headers['authorization'] = 'Bearer ${bearerToken!}';
@ -2286,17 +2291,21 @@ class Api {
/// [serverName] The servers to attempt to knock on the room through. One of the servers /// [serverName] The servers to attempt to knock on the room through. One of the servers
/// must be participating in the room. /// must be participating in the room.
/// ///
/// [via] The servers to attempt to knock on the room through. One of the servers
/// must be participating in the room.
///
/// [reason] Optional reason to be included as the `reason` on the subsequent /// [reason] Optional reason to be included as the `reason` on the subsequent
/// membership event. /// membership event.
/// ///
/// returns `room_id`: /// returns `room_id`:
/// The knocked room ID. /// The knocked room ID.
Future<String> knockRoom(String roomIdOrAlias, Future<String> knockRoom(String roomIdOrAlias,
{List<String>? serverName, String? reason}) async { {List<String>? serverName, List<String>? via, String? reason}) async {
final requestUri = Uri( final requestUri = Uri(
path: '_matrix/client/v3/knock/${Uri.encodeComponent(roomIdOrAlias)}', path: '_matrix/client/v3/knock/${Uri.encodeComponent(roomIdOrAlias)}',
queryParameters: { queryParameters: {
if (serverName != null) 'server_name': serverName, if (serverName != null) 'server_name': serverName,
if (via != null) 'via': via,
}); });
final request = Request('POST', baseUri!.resolveUri(requestUri)); final request = Request('POST', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}'; request.headers['authorization'] = 'Bearer ${bearerToken!}';
@ -2523,8 +2532,7 @@ class Api {
/// Get the combined profile information for this user. This API may be used /// 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 /// to fetch the user's own profile information or other users; either
/// locally or on remote homeservers. This API may return keys which are not /// locally or on remote homeservers.
/// limited to `displayname` or `avatar_url`.
/// ///
/// [userId] The user whose profile information to get. /// [userId] The user whose profile information to get.
Future<ProfileInformation> getUserProfile(String userId) async { Future<ProfileInformation> getUserProfile(String userId) async {
@ -2734,10 +2742,8 @@ class Api {
: null)(json['pushers']); : null)(json['pushers']);
} }
/// Retrieve all push rulesets for this user. Clients can "drill-down" on /// Retrieve all push rulesets for this user. Currently the only push ruleset
/// the rulesets by suffixing a `scope` to this path e.g. /// defined is `global`.
/// `/pushrules/global/`. This will return a subset of this data under the
/// specified key e.g. the `global` key.
/// ///
/// returns `global`: /// returns `global`:
/// The global ruleset. /// The global ruleset.
@ -2753,20 +2759,30 @@ class Api {
return PushRuleSet.fromJson(json['global'] as Map<String, Object?>); return PushRuleSet.fromJson(json['global'] as Map<String, Object?>);
} }
/// Retrieve all push rules for this user.
Future<GetPushRulesGlobalResponse> getPushRulesGlobal() async {
final requestUri = Uri(path: '_matrix/client/v3/pushrules/global/');
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 GetPushRulesGlobalResponse.fromJson(json as Map<String, Object?>);
}
/// This endpoint removes the push rule defined in the path. /// This endpoint removes the push rule defined in the path.
/// ///
/// [scope] `global` to specify global rules.
///
/// [kind] The kind of rule /// [kind] The kind of rule
/// ///
/// ///
/// [ruleId] The identifier for the rule. /// [ruleId] The identifier for the rule.
/// ///
Future<void> deletePushRule( Future<void> deletePushRule(PushRuleKind kind, String ruleId) async {
String scope, PushRuleKind kind, String ruleId) async {
final requestUri = Uri( final requestUri = Uri(
path: path:
'_matrix/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}'); '_matrix/client/v3/pushrules/global/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}');
final request = Request('DELETE', baseUri!.resolveUri(requestUri)); final request = Request('DELETE', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}'; request.headers['authorization'] = 'Bearer ${bearerToken!}';
final response = await httpClient.send(request); final response = await httpClient.send(request);
@ -2779,18 +2795,15 @@ class Api {
/// Retrieve a single specified push rule. /// Retrieve a single specified push rule.
/// ///
/// [scope] `global` to specify global rules.
///
/// [kind] The kind of rule /// [kind] The kind of rule
/// ///
/// ///
/// [ruleId] The identifier for the rule. /// [ruleId] The identifier for the rule.
/// ///
Future<PushRule> getPushRule( Future<PushRule> getPushRule(PushRuleKind kind, String ruleId) async {
String scope, PushRuleKind kind, String ruleId) async {
final requestUri = Uri( final requestUri = Uri(
path: path:
'_matrix/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}'); '_matrix/client/v3/pushrules/global/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}');
final request = Request('GET', baseUri!.resolveUri(requestUri)); final request = Request('GET', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}'; request.headers['authorization'] = 'Bearer ${bearerToken!}';
final response = await httpClient.send(request); final response = await httpClient.send(request);
@ -2818,8 +2831,6 @@ class Api {
/// ///
/// When creating push rules, they MUST be enabled by default. /// When creating push rules, they MUST be enabled by default.
/// ///
/// [scope] `global` to specify global rules.
///
/// [kind] The kind of rule /// [kind] The kind of rule
/// ///
/// ///
@ -2844,14 +2855,14 @@ class Api {
/// ///
/// [pattern] Only applicable to `content` rules. The glob-style pattern to match against. /// [pattern] Only applicable to `content` rules. The glob-style pattern to match against.
Future<void> setPushRule( Future<void> setPushRule(
String scope, PushRuleKind kind, String ruleId, List<Object?> actions, PushRuleKind kind, String ruleId, List<Object?> actions,
{String? before, {String? before,
String? after, String? after,
List<PushCondition>? conditions, List<PushCondition>? conditions,
String? pattern}) async { String? pattern}) async {
final requestUri = Uri( final requestUri = Uri(
path: path:
'_matrix/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}', '_matrix/client/v3/pushrules/global/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}',
queryParameters: { queryParameters: {
if (before != null) 'before': before, if (before != null) 'before': before,
if (after != null) 'after': after, if (after != null) 'after': after,
@ -2875,9 +2886,6 @@ class Api {
/// This endpoint get the actions for the specified push rule. /// This endpoint get the actions for the specified push rule.
/// ///
/// [scope] Either `global` or `device/<profile_tag>` to specify global
/// rules or device rules for the given `profile_tag`.
///
/// [kind] The kind of rule /// [kind] The kind of rule
/// ///
/// ///
@ -2887,10 +2895,10 @@ class Api {
/// returns `actions`: /// returns `actions`:
/// The action(s) to perform for this rule. /// The action(s) to perform for this rule.
Future<List<Object?>> getPushRuleActions( Future<List<Object?>> getPushRuleActions(
String scope, PushRuleKind kind, String ruleId) async { PushRuleKind kind, String ruleId) async {
final requestUri = Uri( final requestUri = Uri(
path: path:
'_matrix/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/actions'); '_matrix/client/v3/pushrules/global/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/actions');
final request = Request('GET', baseUri!.resolveUri(requestUri)); final request = Request('GET', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}'; request.headers['authorization'] = 'Bearer ${bearerToken!}';
final response = await httpClient.send(request); final response = await httpClient.send(request);
@ -2904,8 +2912,6 @@ class Api {
/// This endpoint allows clients to change the actions of a push rule. /// This endpoint allows clients to change the actions of a push rule.
/// This can be used to change the actions of builtin rules. /// This can be used to change the actions of builtin rules.
/// ///
/// [scope] `global` to specify global rules.
///
/// [kind] The kind of rule /// [kind] The kind of rule
/// ///
/// ///
@ -2913,11 +2919,11 @@ class Api {
/// ///
/// ///
/// [actions] The action(s) to perform for this rule. /// [actions] The action(s) to perform for this rule.
Future<void> setPushRuleActions(String scope, PushRuleKind kind, Future<void> setPushRuleActions(
String ruleId, List<Object?> actions) async { PushRuleKind kind, String ruleId, List<Object?> actions) async {
final requestUri = Uri( final requestUri = Uri(
path: path:
'_matrix/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/actions'); '_matrix/client/v3/pushrules/global/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/actions');
final request = Request('PUT', baseUri!.resolveUri(requestUri)); final request = Request('PUT', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}'; request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json'; request.headers['content-type'] = 'application/json';
@ -2934,9 +2940,6 @@ class Api {
/// This endpoint gets whether the specified push rule is enabled. /// This endpoint gets whether the specified push rule is enabled.
/// ///
/// [scope] Either `global` or `device/<profile_tag>` to specify global
/// rules or device rules for the given `profile_tag`.
///
/// [kind] The kind of rule /// [kind] The kind of rule
/// ///
/// ///
@ -2945,11 +2948,10 @@ class Api {
/// ///
/// returns `enabled`: /// returns `enabled`:
/// Whether the push rule is enabled or not. /// Whether the push rule is enabled or not.
Future<bool> isPushRuleEnabled( Future<bool> isPushRuleEnabled(PushRuleKind kind, String ruleId) async {
String scope, PushRuleKind kind, String ruleId) async {
final requestUri = Uri( final requestUri = Uri(
path: path:
'_matrix/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/enabled'); '_matrix/client/v3/pushrules/global/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/enabled');
final request = Request('GET', baseUri!.resolveUri(requestUri)); final request = Request('GET', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}'; request.headers['authorization'] = 'Bearer ${bearerToken!}';
final response = await httpClient.send(request); final response = await httpClient.send(request);
@ -2962,8 +2964,6 @@ class Api {
/// This endpoint allows clients to enable or disable the specified push rule. /// This endpoint allows clients to enable or disable the specified push rule.
/// ///
/// [scope] `global` to specify global rules.
///
/// [kind] The kind of rule /// [kind] The kind of rule
/// ///
/// ///
@ -2972,10 +2972,10 @@ class Api {
/// ///
/// [enabled] Whether the push rule is enabled or not. /// [enabled] Whether the push rule is enabled or not.
Future<void> setPushRuleEnabled( Future<void> setPushRuleEnabled(
String scope, PushRuleKind kind, String ruleId, bool enabled) async { PushRuleKind kind, String ruleId, bool enabled) async {
final requestUri = Uri( final requestUri = Uri(
path: path:
'_matrix/client/v3/pushrules/${Uri.encodeComponent(scope)}/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/enabled'); '_matrix/client/v3/pushrules/global/${Uri.encodeComponent(kind.name)}/${Uri.encodeComponent(ruleId)}/enabled');
final request = Request('PUT', baseUri!.resolveUri(requestUri)); final request = Request('PUT', baseUri!.resolveUri(requestUri));
request.headers['authorization'] = 'Bearer ${bearerToken!}'; request.headers['authorization'] = 'Bearer ${bearerToken!}';
request.headers['content-type'] = 'application/json'; request.headers['content-type'] = 'application/json';
@ -5386,7 +5386,12 @@ class Api {
/// ///
/// [body] /// [body]
/// ///
/// [contentType] The content type of the file being uploaded /// [contentType] **Optional.** The content type of the file being uploaded.
///
/// Clients SHOULD always supply this header.
///
/// Defaults to `application/octet-stream` if it is not set.
///
/// ///
/// returns `content_uri`: /// returns `content_uri`:
/// The [`mxc://` URI](https://spec.matrix.org/unstable/client-server-api/#matrix-content-mxc-uris) to the uploaded content. /// The [`mxc://` URI](https://spec.matrix.org/unstable/client-server-api/#matrix-content-mxc-uris) to the uploaded content.
@ -5422,7 +5427,12 @@ class Api {
/// ///
/// [body] /// [body]
/// ///
/// [contentType] The content type of the file being uploaded /// [contentType] **Optional.** The content type of the file being uploaded.
///
/// Clients SHOULD always supply this header.
///
/// Defaults to `application/octet-stream` if it is not set.
///
Future<Map<String, Object?>> uploadContentToMXC( Future<Map<String, Object?>> uploadContentToMXC(
String serverName, String mediaId, Uint8List body, String serverName, String mediaId, Uint8List body,
{String? filename, String? contentType}) async { {String? filename, String? contentType}) async {

View File

@ -87,7 +87,7 @@ class DiscoveryInformation {
additionalProperties = Map.fromEntries(json.entries additionalProperties = Map.fromEntries(json.entries
.where( .where(
(e) => !['m.homeserver', 'm.identity_server'].contains(e.key)) (e) => !['m.homeserver', 'm.identity_server'].contains(e.key))
.map((e) => MapEntry(e.key, e.value as Map<String, Object?>))); .map((e) => MapEntry(e.key, e.value)));
Map<String, Object?> toJson() { Map<String, Object?> toJson() {
final mIdentityServer = this.mIdentityServer; final mIdentityServer = this.mIdentityServer;
return { return {
@ -104,7 +104,7 @@ class DiscoveryInformation {
/// Used by clients to discover identity server information. /// Used by clients to discover identity server information.
IdentityServerInformation? mIdentityServer; IdentityServerInformation? mIdentityServer;
Map<String, Map<String, Object?>> additionalProperties; Map<String, Object?> additionalProperties;
@dart.override @dart.override
bool operator ==(Object other) => bool operator ==(Object other) =>
@ -1354,24 +1354,24 @@ class WhoIsInfo {
/// ///
@_NameSource('spec') @_NameSource('spec')
class ChangePasswordCapability { class BooleanCapability {
ChangePasswordCapability({ BooleanCapability({
required this.enabled, required this.enabled,
}); });
ChangePasswordCapability.fromJson(Map<String, Object?> json) BooleanCapability.fromJson(Map<String, Object?> json)
: enabled = json['enabled'] as bool; : enabled = json['enabled'] as bool;
Map<String, Object?> toJson() => { Map<String, Object?> toJson() => {
'enabled': enabled, 'enabled': enabled,
}; };
/// True if the user can change their password, false otherwise. /// True if the user can perform the action, false otherwise.
bool enabled; bool enabled;
@dart.override @dart.override
bool operator ==(Object other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is ChangePasswordCapability && (other is BooleanCapability &&
other.runtimeType == runtimeType && other.runtimeType == runtimeType &&
other.enabled == enabled); other.enabled == enabled);
@ -1428,51 +1428,99 @@ class RoomVersionsCapability {
@_NameSource('spec') @_NameSource('spec')
class Capabilities { class Capabilities {
Capabilities({ Capabilities({
this.m3pidChanges,
this.mChangePassword, this.mChangePassword,
this.mGetLoginToken,
this.mRoomVersions, this.mRoomVersions,
this.mSetAvatarUrl,
this.mSetDisplayname,
this.additionalProperties = const {}, this.additionalProperties = const {},
}); });
Capabilities.fromJson(Map<String, Object?> json) Capabilities.fromJson(Map<String, Object?> json)
: mChangePassword = ((v) => v != null : m3pidChanges = ((v) => v != null
? ChangePasswordCapability.fromJson(v as Map<String, Object?>) ? BooleanCapability.fromJson(v as Map<String, Object?>)
: null)(json['m.3pid_changes']),
mChangePassword = ((v) => v != null
? BooleanCapability.fromJson(v as Map<String, Object?>)
: null)(json['m.change_password']), : null)(json['m.change_password']),
mGetLoginToken = ((v) => v != null
? BooleanCapability.fromJson(v as Map<String, Object?>)
: null)(json['m.get_login_token']),
mRoomVersions = ((v) => v != null mRoomVersions = ((v) => v != null
? RoomVersionsCapability.fromJson(v as Map<String, Object?>) ? RoomVersionsCapability.fromJson(v as Map<String, Object?>)
: null)(json['m.room_versions']), : null)(json['m.room_versions']),
mSetAvatarUrl = ((v) => v != null
? BooleanCapability.fromJson(v as Map<String, Object?>)
: null)(json['m.set_avatar_url']),
mSetDisplayname = ((v) => v != null
? BooleanCapability.fromJson(v as Map<String, Object?>)
: null)(json['m.set_displayname']),
additionalProperties = Map.fromEntries(json.entries additionalProperties = Map.fromEntries(json.entries
.where((e) => .where((e) => ![
!['m.change_password', 'm.room_versions'].contains(e.key)) 'm.3pid_changes',
.map((e) => MapEntry(e.key, e.value as Map<String, Object?>))); 'm.change_password',
'm.get_login_token',
'm.room_versions',
'm.set_avatar_url',
'm.set_displayname'
].contains(e.key))
.map((e) => MapEntry(e.key, e.value)));
Map<String, Object?> toJson() { Map<String, Object?> toJson() {
final m3pidChanges = this.m3pidChanges;
final mChangePassword = this.mChangePassword; final mChangePassword = this.mChangePassword;
final mGetLoginToken = this.mGetLoginToken;
final mRoomVersions = this.mRoomVersions; final mRoomVersions = this.mRoomVersions;
final mSetAvatarUrl = this.mSetAvatarUrl;
final mSetDisplayname = this.mSetDisplayname;
return { return {
...additionalProperties, ...additionalProperties,
if (m3pidChanges != null) 'm.3pid_changes': m3pidChanges.toJson(),
if (mChangePassword != null) if (mChangePassword != null)
'm.change_password': mChangePassword.toJson(), 'm.change_password': mChangePassword.toJson(),
if (mGetLoginToken != null) 'm.get_login_token': mGetLoginToken.toJson(),
if (mRoomVersions != null) 'm.room_versions': mRoomVersions.toJson(), if (mRoomVersions != null) 'm.room_versions': mRoomVersions.toJson(),
if (mSetAvatarUrl != null) 'm.set_avatar_url': mSetAvatarUrl.toJson(),
if (mSetDisplayname != null)
'm.set_displayname': mSetDisplayname.toJson(),
}; };
} }
/// Capability to indicate if the user can change 3PID associations on their account.
BooleanCapability? m3pidChanges;
/// Capability to indicate if the user can change their password. /// Capability to indicate if the user can change their password.
ChangePasswordCapability? mChangePassword; BooleanCapability? mChangePassword;
/// Capability to indicate if the user can generate tokens to log further clients into their account.
BooleanCapability? mGetLoginToken;
/// The room versions the server supports. /// The room versions the server supports.
RoomVersionsCapability? mRoomVersions; RoomVersionsCapability? mRoomVersions;
Map<String, Map<String, Object?>> additionalProperties; /// Capability to indicate if the user can change their avatar.
BooleanCapability? mSetAvatarUrl;
/// Capability to indicate if the user can change their display name.
BooleanCapability? mSetDisplayname;
Map<String, Object?> additionalProperties;
@dart.override @dart.override
bool operator ==(Object other) => bool operator ==(Object other) =>
identical(this, other) || identical(this, other) ||
(other is Capabilities && (other is Capabilities &&
other.runtimeType == runtimeType && other.runtimeType == runtimeType &&
other.m3pidChanges == m3pidChanges &&
other.mChangePassword == mChangePassword && other.mChangePassword == mChangePassword &&
other.mRoomVersions == mRoomVersions); other.mGetLoginToken == mGetLoginToken &&
other.mRoomVersions == mRoomVersions &&
other.mSetAvatarUrl == mSetAvatarUrl &&
other.mSetDisplayname == mSetDisplayname);
@dart.override @dart.override
int get hashCode => Object.hash(mChangePassword, mRoomVersions); int get hashCode => Object.hash(m3pidChanges, mChangePassword, mGetLoginToken,
mRoomVersions, mSetAvatarUrl, mSetDisplayname);
} }
/// ///
@ -3006,6 +3054,90 @@ class PushRuleSet {
int get hashCode => Object.hash(content, override, room, sender, underride); int get hashCode => Object.hash(content, override, room, sender, underride);
} }
///
@_NameSource('generated')
class GetPushRulesGlobalResponse {
GetPushRulesGlobalResponse({
this.content,
this.override,
this.room,
this.sender,
this.underride,
});
GetPushRulesGlobalResponse.fromJson(Map<String, Object?> json)
: content = ((v) => v != null
? (v as List)
.map((v) => PushRule.fromJson(v as Map<String, Object?>))
.toList()
: null)(json['content']),
override = ((v) => v != null
? (v as List)
.map((v) => PushRule.fromJson(v as Map<String, Object?>))
.toList()
: null)(json['override']),
room = ((v) => v != null
? (v as List)
.map((v) => PushRule.fromJson(v as Map<String, Object?>))
.toList()
: null)(json['room']),
sender = ((v) => v != null
? (v as List)
.map((v) => PushRule.fromJson(v as Map<String, Object?>))
.toList()
: null)(json['sender']),
underride = ((v) => v != null
? (v as List)
.map((v) => PushRule.fromJson(v as Map<String, Object?>))
.toList()
: null)(json['underride']);
Map<String, Object?> toJson() {
final content = this.content;
final override = this.override;
final room = this.room;
final sender = this.sender;
final underride = this.underride;
return {
if (content != null) 'content': content.map((v) => v.toJson()).toList(),
if (override != null)
'override': override.map((v) => v.toJson()).toList(),
if (room != null) 'room': room.map((v) => v.toJson()).toList(),
if (sender != null) 'sender': sender.map((v) => v.toJson()).toList(),
if (underride != null)
'underride': underride.map((v) => v.toJson()).toList(),
};
}
///
List<PushRule>? content;
///
List<PushRule>? override;
///
List<PushRule>? room;
///
List<PushRule>? sender;
///
List<PushRule>? underride;
@dart.override
bool operator ==(Object other) =>
identical(this, other) ||
(other is GetPushRulesGlobalResponse &&
other.runtimeType == runtimeType &&
other.content == content &&
other.override == override &&
other.room == room &&
other.sender == sender &&
other.underride == underride);
@dart.override
int get hashCode => Object.hash(content, override, room, sender, underride);
}
/// ///
@_NameSource('rule override generated') @_NameSource('rule override generated')
@EnhancedEnum() @EnhancedEnum()
@ -4734,7 +4866,7 @@ class FieldType {
'regexp': regexp, 'regexp': regexp,
}; };
/// An placeholder serving as a valid example of the field value. /// A placeholder serving as a valid example of the field value.
String placeholder; String placeholder;
/// A regular expression for validation of a field's value. This may be relatively /// A regular expression for validation of a field's value. This may be relatively
@ -4836,9 +4968,9 @@ class Protocol {
'user_fields': userFields.map((v) => v).toList(), 'user_fields': userFields.map((v) => v).toList(),
}; };
/// The type definitions for the fields defined in the `user_fields` and /// The type definitions for the fields defined in `user_fields` and
/// `location_fields`. Each entry in those arrays MUST have an entry here. The /// `location_fields`. Each entry in those arrays MUST have an entry here.
/// `string` key for this object is field name itself. /// The `string` key for this object is the field name itself.
/// ///
/// May be an empty object if no fields are defined. /// May be an empty object if no fields are defined.
Map<String, FieldType> fieldTypes; Map<String, FieldType> fieldTypes;
@ -4904,7 +5036,7 @@ class ThirdPartyUser {
/// The protocol ID that the third-party location is a part of. /// The protocol ID that the third-party location is a part of.
String protocol; String protocol;
/// A Matrix User ID represting a third-party user. /// A Matrix User ID representing a third-party user.
String userid; String userid;
@dart.override @dart.override

View File

@ -3369,7 +3369,6 @@ class Client extends MatrixApi {
Future<void> setMuteAllPushNotifications(bool muted) async { Future<void> setMuteAllPushNotifications(bool muted) async {
await setPushRuleEnabled( await setPushRuleEnabled(
'global',
PushRuleKind.override, PushRuleKind.override,
'.m.rule.master', '.m.rule.master',
muted, muted,
@ -3377,6 +3376,22 @@ class Client extends MatrixApi {
return; return;
} }
/// preference is always given to via over serverName, irrespective of what field
/// you are trying to use
@override
Future<String> joinRoom(String roomIdOrAlias,
{List<String>? serverName,
List<String>? via,
String? reason,
ThirdPartySigned? thirdPartySigned}) =>
super.joinRoom(
roomIdOrAlias,
serverName: via ?? serverName,
via: via ?? serverName,
reason: reason,
thirdPartySigned: thirdPartySigned,
);
/// Changes the password. You should either set oldPasswort or another authentication flow. /// Changes the password. You should either set oldPasswort or another authentication flow.
@override @override
Future<void> changePassword( Future<void> changePassword(

View File

@ -2067,24 +2067,22 @@ class Room {
// All push notifications should be sent to the user // All push notifications should be sent to the user
case PushRuleState.notify: case PushRuleState.notify:
if (pushRuleState == PushRuleState.dontNotify) { if (pushRuleState == PushRuleState.dontNotify) {
await client.deletePushRule('global', PushRuleKind.override, id); await client.deletePushRule(PushRuleKind.override, id);
} else if (pushRuleState == PushRuleState.mentionsOnly) { } else if (pushRuleState == PushRuleState.mentionsOnly) {
await client.deletePushRule('global', PushRuleKind.room, id); await client.deletePushRule(PushRuleKind.room, id);
} }
break; break;
// Only when someone mentions the user, a push notification should be sent // Only when someone mentions the user, a push notification should be sent
case PushRuleState.mentionsOnly: case PushRuleState.mentionsOnly:
if (pushRuleState == PushRuleState.dontNotify) { if (pushRuleState == PushRuleState.dontNotify) {
await client.deletePushRule('global', PushRuleKind.override, id); await client.deletePushRule(PushRuleKind.override, id);
await client.setPushRule( await client.setPushRule(
'global',
PushRuleKind.room, PushRuleKind.room,
id, id,
[PushRuleAction.dontNotify], [PushRuleAction.dontNotify],
); );
} else if (pushRuleState == PushRuleState.notify) { } else if (pushRuleState == PushRuleState.notify) {
await client.setPushRule( await client.setPushRule(
'global',
PushRuleKind.room, PushRuleKind.room,
id, id,
[PushRuleAction.dontNotify], [PushRuleAction.dontNotify],
@ -2094,10 +2092,9 @@ class Room {
// No push notification should be ever sent for this room. // No push notification should be ever sent for this room.
case PushRuleState.dontNotify: case PushRuleState.dontNotify:
if (pushRuleState == PushRuleState.mentionsOnly) { if (pushRuleState == PushRuleState.mentionsOnly) {
await client.deletePushRule('global', PushRuleKind.room, id); await client.deletePushRule(PushRuleKind.room, id);
} }
await client.setPushRule( await client.setPushRule(
'global',
PushRuleKind.override, PushRuleKind.override,
id, id,
[PushRuleAction.dontNotify], [PushRuleAction.dontNotify],