getThreadRoots method
Paginates over the thread roots in a room, ordered by the latest_event
of each thread root
in its bundle.
roomId
The room ID where the thread roots are located.
include
Optional (default all
) flag to denote which thread roots are of interest to the caller.
When all
, all thread roots found in the room are returned. When participated
, only
thread roots for threads the user has participated in
will be returned.
limit
Optional limit for the maximum number of thread roots to include per response. Must be an integer
greater than zero.
Servers should apply a default value, and impose a maximum value to avoid resource exhaustion.
from
A pagination token from a previous result. When not provided, the server starts paginating from
the most recent event visible to the user (as per history visibility rules; topologically).
Implementation
Future<GetThreadRootsResponse> getThreadRoots(String roomId,
{Include? include, int? limit, String? from}) async {
final requestUri = Uri(
path: '_api/client/v1/rooms/${Uri.encodeComponent(roomId)}/threads',
queryParameters: {
if (include != null) 'include': include.name,
if (limit != null) 'limit': limit.toString(),
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 GetThreadRootsResponse.fromJson(json as Map<String, Object?>);
}