getLocalAliases method
Get a list of aliases maintained by the local server for the given room.
This endpoint can be called by users who are in the room (external
users receive an M_FORBIDDEN
error response). If the room's
m.room.history_visibility
maps to world_readable
, any
user can call this endpoint.
Servers may choose to implement additional access control checks here, such as allowing server administrators to view aliases regardless of membership.
Note:
Clients are recommended not to display this list of aliases prominently
as they are not curated, unlike those listed in the m.room.canonical_alias
state event.
roomId
The room ID to find local aliases of.
returns aliases
:
The server's local aliases on the room. Can be empty.
Implementation
Future<List<String>> getLocalAliases(String roomId) async {
final requestUri = Uri(
path: '_matrix/client/v3/rooms/${Uri.encodeComponent(roomId)}/aliases',
);
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['aliases'] as List).map((v) => v as String).toList();
}