fix: wrong types in spaces hierarchy API
BREAKING CHANGE (because from is now optional, so it can't be specified conditionally) See also: - https://github.com/matrix-org/matrix-spec/pull/1110 - https://github.com/matrix-org/matrix-spec/pull/1097
This commit is contained in:
parent
fc4f004312
commit
3dd7ef3444
|
|
@ -98,10 +98,7 @@ class Api {
|
||||||
/// [from] A pagination token from a previous result. If specified, `max_depth` and `suggested_only` cannot
|
/// [from] A pagination token from a previous result. If specified, `max_depth` and `suggested_only` cannot
|
||||||
/// be changed from the first request.
|
/// be changed from the first request.
|
||||||
Future<GetSpaceHierarchyResponse> getSpaceHierarchy(String roomId,
|
Future<GetSpaceHierarchyResponse> getSpaceHierarchy(String roomId,
|
||||||
{bool? suggestedOnly,
|
{bool? suggestedOnly, int? limit, int? maxDepth, String? from}) async {
|
||||||
double? limit,
|
|
||||||
double? maxDepth,
|
|
||||||
String? from}) async {
|
|
||||||
final requestUri = Uri(
|
final requestUri = Uri(
|
||||||
path:
|
path:
|
||||||
'_matrix/client/v1/rooms/${Uri.encodeComponent(roomId)}/hierarchy',
|
'_matrix/client/v1/rooms/${Uri.encodeComponent(roomId)}/hierarchy',
|
||||||
|
|
@ -3234,6 +3231,10 @@ class Api {
|
||||||
/// by a previous request to this endpoint, though servers are not
|
/// by a previous request to this endpoint, though servers are not
|
||||||
/// required to support this. Clients should not rely on the behaviour.
|
/// required to support this. Clients should not rely on the behaviour.
|
||||||
///
|
///
|
||||||
|
/// If it is not provided, the homeserver shall return a list of messages
|
||||||
|
/// from the first or last (per the value of the `dir` parameter) visible
|
||||||
|
/// event in the room history for the requesting user.
|
||||||
|
///
|
||||||
/// [to] The token to stop returning events at. This token can be obtained from
|
/// [to] The token to stop returning events at. This token can be obtained from
|
||||||
/// a `prev_batch` or `next_batch` token returned by the `/sync` endpoint,
|
/// a `prev_batch` or `next_batch` token returned by the `/sync` endpoint,
|
||||||
/// or from an `end` token returned by a previous request to this endpoint.
|
/// or from an `end` token returned by a previous request to this endpoint.
|
||||||
|
|
@ -3246,13 +3247,12 @@ class Api {
|
||||||
/// [limit] The maximum number of events to return. Default: 10.
|
/// [limit] The maximum number of events to return. Default: 10.
|
||||||
///
|
///
|
||||||
/// [filter] A JSON RoomEventFilter to filter returned events with.
|
/// [filter] A JSON RoomEventFilter to filter returned events with.
|
||||||
Future<GetRoomEventsResponse> getRoomEvents(
|
Future<GetRoomEventsResponse> getRoomEvents(String roomId, Direction dir,
|
||||||
String roomId, String from, Direction dir,
|
{String? from, String? to, int? limit, String? filter}) async {
|
||||||
{String? to, int? limit, String? filter}) async {
|
|
||||||
final requestUri = Uri(
|
final requestUri = Uri(
|
||||||
path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/messages',
|
path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/messages',
|
||||||
queryParameters: {
|
queryParameters: {
|
||||||
'from': from,
|
if (from != null) 'from': from,
|
||||||
if (to != null) 'to': to,
|
if (to != null) 'to': to,
|
||||||
'dir': dir.name,
|
'dir': dir.name,
|
||||||
if (limit != null) 'limit': limit.toString(),
|
if (limit != null) 'limit': limit.toString(),
|
||||||
|
|
|
||||||
|
|
@ -164,18 +164,21 @@ class PublicRoomsChunk {
|
||||||
class SpaceRoomsChunkBase {
|
class SpaceRoomsChunkBase {
|
||||||
SpaceRoomsChunkBase({
|
SpaceRoomsChunkBase({
|
||||||
required this.childrenState,
|
required this.childrenState,
|
||||||
required this.roomType,
|
this.roomType,
|
||||||
});
|
});
|
||||||
|
|
||||||
SpaceRoomsChunkBase.fromJson(Map<String, dynamic> json)
|
SpaceRoomsChunkBase.fromJson(Map<String, dynamic> json)
|
||||||
: childrenState = (json['children_state'] as List)
|
: childrenState = (json['children_state'] as List)
|
||||||
.map((v) => MatrixEvent.fromJson(v))
|
.map((v) => MatrixEvent.fromJson(v))
|
||||||
.toList(),
|
.toList(),
|
||||||
roomType = json['room_type'] as String;
|
roomType = ((v) => v != null ? v as String : null)(json['room_type']);
|
||||||
Map<String, dynamic> toJson() => {
|
Map<String, dynamic> toJson() {
|
||||||
'children_state': childrenState.map((v) => v.toJson()).toList(),
|
final roomType = this.roomType;
|
||||||
'room_type': roomType,
|
return {
|
||||||
};
|
'children_state': childrenState.map((v) => v.toJson()).toList(),
|
||||||
|
if (roomType != null) 'room_type': roomType,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// The [`m.space.child`](#mspacechild) events of the space-room, represented
|
/// The [`m.space.child`](#mspacechild) events of the space-room, represented
|
||||||
/// as [Stripped State Events](#stripped-state) with an added `origin_server_ts` key.
|
/// as [Stripped State Events](#stripped-state) with an added `origin_server_ts` key.
|
||||||
|
|
@ -184,7 +187,7 @@ class SpaceRoomsChunkBase {
|
||||||
List<MatrixEvent> childrenState;
|
List<MatrixEvent> childrenState;
|
||||||
|
|
||||||
/// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any.
|
/// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any.
|
||||||
String roomType;
|
String? roomType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@_NameSource('rule override generated')
|
@_NameSource('rule override generated')
|
||||||
|
|
@ -200,7 +203,7 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase {
|
||||||
this.topic,
|
this.topic,
|
||||||
required this.worldReadable,
|
required this.worldReadable,
|
||||||
required this.childrenState,
|
required this.childrenState,
|
||||||
required this.roomType,
|
this.roomType,
|
||||||
});
|
});
|
||||||
|
|
||||||
SpaceRoomsChunk.fromJson(Map<String, dynamic> json)
|
SpaceRoomsChunk.fromJson(Map<String, dynamic> json)
|
||||||
|
|
@ -218,13 +221,14 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase {
|
||||||
childrenState = (json['children_state'] as List)
|
childrenState = (json['children_state'] as List)
|
||||||
.map((v) => MatrixEvent.fromJson(v))
|
.map((v) => MatrixEvent.fromJson(v))
|
||||||
.toList(),
|
.toList(),
|
||||||
roomType = json['room_type'] as String;
|
roomType = ((v) => v != null ? v as String : null)(json['room_type']);
|
||||||
Map<String, dynamic> toJson() {
|
Map<String, dynamic> toJson() {
|
||||||
final avatarUrl = this.avatarUrl;
|
final avatarUrl = this.avatarUrl;
|
||||||
final canonicalAlias = this.canonicalAlias;
|
final canonicalAlias = this.canonicalAlias;
|
||||||
final joinRule = this.joinRule;
|
final joinRule = this.joinRule;
|
||||||
final name = this.name;
|
final name = this.name;
|
||||||
final topic = this.topic;
|
final topic = this.topic;
|
||||||
|
final roomType = this.roomType;
|
||||||
return {
|
return {
|
||||||
if (avatarUrl != null) 'avatar_url': avatarUrl.toString(),
|
if (avatarUrl != null) 'avatar_url': avatarUrl.toString(),
|
||||||
if (canonicalAlias != null) 'canonical_alias': canonicalAlias,
|
if (canonicalAlias != null) 'canonical_alias': canonicalAlias,
|
||||||
|
|
@ -236,7 +240,7 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase {
|
||||||
if (topic != null) 'topic': topic,
|
if (topic != null) 'topic': topic,
|
||||||
'world_readable': worldReadable,
|
'world_readable': worldReadable,
|
||||||
'children_state': childrenState.map((v) => v.toJson()).toList(),
|
'children_state': childrenState.map((v) => v.toJson()).toList(),
|
||||||
'room_type': roomType,
|
if (roomType != null) 'room_type': roomType,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -277,7 +281,7 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase {
|
||||||
List<MatrixEvent> childrenState;
|
List<MatrixEvent> childrenState;
|
||||||
|
|
||||||
/// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any.
|
/// The `type` of room (from [`m.room.create`](https://spec.matrix.org/unstable/client-server-api/#mroomcreate)), if any.
|
||||||
String roomType;
|
String? roomType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@_NameSource('generated')
|
@_NameSource('generated')
|
||||||
|
|
|
||||||
|
|
@ -566,8 +566,8 @@ void main() {
|
||||||
|
|
||||||
final timelineHistoryResponse = await matrixApi.getRoomEvents(
|
final timelineHistoryResponse = await matrixApi.getRoomEvents(
|
||||||
'!localpart:server.abc',
|
'!localpart:server.abc',
|
||||||
'1234',
|
|
||||||
Direction.b,
|
Direction.b,
|
||||||
|
from: '1234',
|
||||||
limit: 10,
|
limit: 10,
|
||||||
filter: '{"lazy_load_members":true}',
|
filter: '{"lazy_load_members":true}',
|
||||||
to: '1234',
|
to: '1234',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue