getMutualRooms method

Future<GetMutualRoomsResponse> getMutualRooms(
  1. String userId, {
  2. String? from,
})

Get the list of rooms that the user shares with another user. The server will return a list of room IDs that the user shares with the specified user_id.

userId The MXID of the user to check for mutual rooms with.

from A pagination token from a previous result. This should be a next_batch result from a previous call to this endpoint. If not provided, the server will return the first batch of results.

Implementation

Future<GetMutualRoomsResponse> getMutualRooms(
  String userId, {
  String? from,
}) async {
  final requestUri = Uri(
    path: '_matrix/client/v1/mutual_rooms',
    queryParameters: {'user_id': userId, if (from != null) 'from': from},
  );
  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 GetMutualRoomsResponse.fromJson(json as Map<String, Object?>);
}