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
|
||||
/// be changed from the first request.
|
||||
Future<GetSpaceHierarchyResponse> getSpaceHierarchy(String roomId,
|
||||
{bool? suggestedOnly,
|
||||
double? limit,
|
||||
double? maxDepth,
|
||||
String? from}) async {
|
||||
{bool? suggestedOnly, int? limit, int? maxDepth, String? from}) async {
|
||||
final requestUri = Uri(
|
||||
path:
|
||||
'_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
|
||||
/// 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
|
||||
/// 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.
|
||||
|
|
@ -3246,13 +3247,12 @@ class Api {
|
|||
/// [limit] The maximum number of events to return. Default: 10.
|
||||
///
|
||||
/// [filter] A JSON RoomEventFilter to filter returned events with.
|
||||
Future<GetRoomEventsResponse> getRoomEvents(
|
||||
String roomId, String from, Direction dir,
|
||||
{String? to, int? limit, String? filter}) async {
|
||||
Future<GetRoomEventsResponse> getRoomEvents(String roomId, Direction dir,
|
||||
{String? from, String? to, int? limit, String? filter}) async {
|
||||
final requestUri = Uri(
|
||||
path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/messages',
|
||||
queryParameters: {
|
||||
'from': from,
|
||||
if (from != null) 'from': from,
|
||||
if (to != null) 'to': to,
|
||||
'dir': dir.name,
|
||||
if (limit != null) 'limit': limit.toString(),
|
||||
|
|
|
|||
|
|
@ -164,18 +164,21 @@ class PublicRoomsChunk {
|
|||
class SpaceRoomsChunkBase {
|
||||
SpaceRoomsChunkBase({
|
||||
required this.childrenState,
|
||||
required this.roomType,
|
||||
this.roomType,
|
||||
});
|
||||
|
||||
SpaceRoomsChunkBase.fromJson(Map<String, dynamic> json)
|
||||
: childrenState = (json['children_state'] as List)
|
||||
.map((v) => MatrixEvent.fromJson(v))
|
||||
.toList(),
|
||||
roomType = json['room_type'] as String;
|
||||
Map<String, dynamic> toJson() => {
|
||||
roomType = ((v) => v != null ? v as String : null)(json['room_type']);
|
||||
Map<String, dynamic> toJson() {
|
||||
final roomType = this.roomType;
|
||||
return {
|
||||
'children_state': childrenState.map((v) => v.toJson()).toList(),
|
||||
'room_type': roomType,
|
||||
if (roomType != null) 'room_type': roomType,
|
||||
};
|
||||
}
|
||||
|
||||
/// The [`m.space.child`](#mspacechild) events of the space-room, represented
|
||||
/// as [Stripped State Events](#stripped-state) with an added `origin_server_ts` key.
|
||||
|
|
@ -184,7 +187,7 @@ class SpaceRoomsChunkBase {
|
|||
List<MatrixEvent> childrenState;
|
||||
|
||||
/// 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')
|
||||
|
|
@ -200,7 +203,7 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase {
|
|||
this.topic,
|
||||
required this.worldReadable,
|
||||
required this.childrenState,
|
||||
required this.roomType,
|
||||
this.roomType,
|
||||
});
|
||||
|
||||
SpaceRoomsChunk.fromJson(Map<String, dynamic> json)
|
||||
|
|
@ -218,13 +221,14 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase {
|
|||
childrenState = (json['children_state'] as List)
|
||||
.map((v) => MatrixEvent.fromJson(v))
|
||||
.toList(),
|
||||
roomType = json['room_type'] as String;
|
||||
roomType = ((v) => v != null ? v as String : null)(json['room_type']);
|
||||
Map<String, dynamic> toJson() {
|
||||
final avatarUrl = this.avatarUrl;
|
||||
final canonicalAlias = this.canonicalAlias;
|
||||
final joinRule = this.joinRule;
|
||||
final name = this.name;
|
||||
final topic = this.topic;
|
||||
final roomType = this.roomType;
|
||||
return {
|
||||
if (avatarUrl != null) 'avatar_url': avatarUrl.toString(),
|
||||
if (canonicalAlias != null) 'canonical_alias': canonicalAlias,
|
||||
|
|
@ -236,7 +240,7 @@ class SpaceRoomsChunk implements PublicRoomsChunk, SpaceRoomsChunkBase {
|
|||
if (topic != null) 'topic': topic,
|
||||
'world_readable': worldReadable,
|
||||
'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;
|
||||
|
||||
/// 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')
|
||||
|
|
|
|||
|
|
@ -566,8 +566,8 @@ void main() {
|
|||
|
||||
final timelineHistoryResponse = await matrixApi.getRoomEvents(
|
||||
'!localpart:server.abc',
|
||||
'1234',
|
||||
Direction.b,
|
||||
from: '1234',
|
||||
limit: 10,
|
||||
filter: '{"lazy_load_members":true}',
|
||||
to: '1234',
|
||||
|
|
|
|||
Loading…
Reference in New Issue