getAccountDataPerRoom method

Future<Map<String, Object?>> getAccountDataPerRoom(
  1. String userId,
  2. String roomId,
  3. String type
)

Get some account data for the client on a given room. This config is only visible to the user that set the account data.

userId The ID of the user to get account data for. The access token must be authorized to make requests for this user ID.

roomId The ID of the room to get account data for.

type The event type of the account data to get. Custom types should be namespaced to avoid clashes.

Implementation

Future<Map<String, Object?>> getAccountDataPerRoom(
  String userId,
  String roomId,
  String type,
) async {
  final requestUri = Uri(
    path:
        '_matrix/client/v3/user/${Uri.encodeComponent(userId)}/rooms/${Uri.encodeComponent(roomId)}/account_data/${Uri.encodeComponent(type)}',
  );
  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 json as Map<String, Object?>;
}