feat: Enhanced alias handling
This commit is contained in:
parent
fdf650abd5
commit
70ee808911
|
|
@ -251,6 +251,18 @@ class Room {
|
||||||
? getState(EventTypes.RoomCanonicalAlias).content['alias']
|
? getState(EventTypes.RoomCanonicalAlias).content['alias']
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
|
/// Sets the canonical alias. If the [canonicalAlias] is not yet an alias of
|
||||||
|
/// this room, it will create one.
|
||||||
|
Future<void> setCanonicalAlias(String canonicalAlias) async {
|
||||||
|
final aliases = await client.requestRoomAliases(id);
|
||||||
|
if (!aliases.contains(canonicalAlias)) {
|
||||||
|
await client.createRoomAlias(canonicalAlias, id);
|
||||||
|
}
|
||||||
|
await client.sendState(id, EventTypes.RoomCanonicalAlias, {
|
||||||
|
'alias': canonicalAlias,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// If this room is a direct chat, this is the matrix ID of the user.
|
/// If this room is a direct chat, this is the matrix ID of the user.
|
||||||
/// Returns null otherwise.
|
/// Returns null otherwise.
|
||||||
String get directChatMatrixID {
|
String get directChatMatrixID {
|
||||||
|
|
@ -1643,17 +1655,6 @@ class Room {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns all aliases for this room.
|
|
||||||
List<String> get aliases {
|
|
||||||
final aliases = <String>[];
|
|
||||||
for (final aliasEvent in states[EventTypes.RoomAliases].values) {
|
|
||||||
if (aliasEvent.content['aliases'] is List) {
|
|
||||||
aliases.addAll(aliasEvent.content['aliases']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return aliases;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A room may be public meaning anyone can join the room without any prior action. Alternatively,
|
/// A room may be public meaning anyone can join the room without any prior action. Alternatively,
|
||||||
/// it can be invite meaning that a user who wishes to join the room must first receive an invite
|
/// it can be invite meaning that a user who wishes to join the room must first receive an invite
|
||||||
/// to the room from someone already inside of the room. Currently, knock and private are reserved
|
/// to the room from someone already inside of the room. Currently, knock and private are reserved
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ dependencies:
|
||||||
olm: ^2.0.0
|
olm: ^2.0.0
|
||||||
isolate: ^2.0.3
|
isolate: ^2.0.3
|
||||||
logger: ^1.0.0
|
logger: ^1.0.0
|
||||||
matrix_api_lite: ^0.2.4
|
matrix_api_lite: ^0.2.6
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
test: ^1.15.7
|
test: ^1.15.7
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue