getRoomVisibilityOnDirectory method

Future<Visibility?> getRoomVisibilityOnDirectory(
  1. String roomId
)
inherited

Gets the visibility of a given room on the server's public room directory.

roomId The room ID.

returns visibility: The visibility of the room in the directory.

Implementation

Future<Visibility?> getRoomVisibilityOnDirectory(String roomId) async {
  final requestUri = Uri(
      path:
          '_api/client/v3/directory/list/room/${Uri.encodeComponent(roomId)}');
  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 ((v) => v != null
      ? Visibility.values.fromString(v as String)!
      : null)(json['visibility']);
}