deleteRoomAlias method
Remove a mapping of room alias to room ID.
Servers may choose to implement additional access control checks here, for instance that room aliases can only be deleted by their creator or a server administrator.
Note:
Servers may choose to update the alt_aliases
for the m.room.canonical_alias
state event in the room when an alias is removed. Servers which choose to update the
canonical alias event are recommended to, in addition to their other relevant permission
checks, delete the alias and return a successful response even if the user does not
have permission to update the m.room.canonical_alias
event.
roomAlias
The room alias to remove. Its format is defined
in the appendices.
Implementation
Future<void> deleteRoomAlias(String roomAlias) async {
final requestUri = Uri(
path:
'_api/client/v3/directory/room/${Uri.encodeComponent(roomAlias)}');
final request = Request('DELETE', 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 ignore(json);
}