mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 15:02:33 +01:00
fix: Allow joining of unpublished aliases again
This commit is contained in:
parent
2c3c0dbdb2
commit
ed570a6e1e
@ -35,7 +35,6 @@ class UrlLauncher {
|
|||||||
// we got a room! Let's open that one
|
// we got a room! Let's open that one
|
||||||
final roomIdOrAlias = identityParts.primaryIdentifier;
|
final roomIdOrAlias = identityParts.primaryIdentifier;
|
||||||
final event = identityParts.secondaryIdentifier;
|
final event = identityParts.secondaryIdentifier;
|
||||||
final query = identityParts.queryString;
|
|
||||||
var room = matrix.client.getRoomByAlias(roomIdOrAlias) ??
|
var room = matrix.client.getRoomByAlias(roomIdOrAlias) ??
|
||||||
matrix.client.getRoomById(roomIdOrAlias);
|
matrix.client.getRoomById(roomIdOrAlias);
|
||||||
var roomId = room?.id;
|
var roomId = room?.id;
|
||||||
@ -49,26 +48,15 @@ class UrlLauncher {
|
|||||||
future: () =>
|
future: () =>
|
||||||
matrix.client.requestRoomAliasInformations(roomIdOrAlias),
|
matrix.client.requestRoomAliasInformations(roomIdOrAlias),
|
||||||
);
|
);
|
||||||
if (response.error == null) {
|
if (response.error != null) {
|
||||||
|
return; // nothing to do, the alias doesn't exist
|
||||||
|
}
|
||||||
roomId = response.result.roomId;
|
roomId = response.result.roomId;
|
||||||
servers.addAll(response.result.servers);
|
servers.addAll(response.result.servers);
|
||||||
room = matrix.client.getRoomById(roomId);
|
room = matrix.client.getRoomById(roomId);
|
||||||
}
|
}
|
||||||
}
|
if (identityParts.via != null) {
|
||||||
if (query != null) {
|
servers.addAll(identityParts.via);
|
||||||
// the query information might hold additional servers to try, so let's try them!
|
|
||||||
// as there might be multiple "via" tags we can't just use Uri.splitQueryString, we need to do our own thing
|
|
||||||
for (final parameter in query.split('&')) {
|
|
||||||
final index = parameter.indexOf('=');
|
|
||||||
if (index == -1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (Uri.decodeQueryComponent(parameter.substring(0, index)) !=
|
|
||||||
'via') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
servers.add(Uri.decodeQueryComponent(parameter.substring(index + 1)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
// we have the room, so....just open it!
|
// we have the room, so....just open it!
|
||||||
|
@ -116,10 +116,25 @@ class _DiscoverPageState extends State<DiscoverPage> {
|
|||||||
final server = _genericSearchTerm?.isValidMatrixId ?? false
|
final server = _genericSearchTerm?.isValidMatrixId ?? false
|
||||||
? _genericSearchTerm.domain
|
? _genericSearchTerm.domain
|
||||||
: _server;
|
: _server;
|
||||||
_publicRoomsResponse ??= Matrix.of(context).client.searchPublicRooms(
|
_publicRoomsResponse ??= Matrix.of(context)
|
||||||
|
.client
|
||||||
|
.searchPublicRooms(
|
||||||
server: server,
|
server: server,
|
||||||
genericSearchTerm: _genericSearchTerm,
|
genericSearchTerm: _genericSearchTerm,
|
||||||
);
|
)
|
||||||
|
.then((PublicRoomsResponse res) {
|
||||||
|
if (widget.alias != null &&
|
||||||
|
!res.chunk.any((room) =>
|
||||||
|
room.aliases.contains(widget.alias) ||
|
||||||
|
room.canonicalAlias == widget.alias)) {
|
||||||
|
// we have to tack on the original alias
|
||||||
|
res.chunk.add(PublicRoom.fromJson(<String, dynamic>{
|
||||||
|
'aliases': [widget.alias],
|
||||||
|
'name': widget.alias,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
});
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
leading: BackButton(),
|
leading: BackButton(),
|
||||||
|
Loading…
Reference in New Issue
Block a user