handle case where there's no alias

This commit is contained in:
H. Shay 2024-08-22 14:14:18 -07:00
parent de11771230
commit 914af63c37

View File

@ -661,11 +661,17 @@ export class PolicyListManager {
let roomId: string; let roomId: string;
let viaServers: string[]; let viaServers: string[];
if (permalink.roomIdOrAlias.startsWith("!")) { if (permalink.roomIdOrAlias.startsWith("!")) {
// get alias and then use alias to get via servers // if we only have a room id, see if there's an alias we can use to get any possible
// via servers
const alias = await this.mjolnir.client.getPublishedAlias(permalink.roomIdOrAlias) const alias = await this.mjolnir.client.getPublishedAlias(permalink.roomIdOrAlias)
const roomInformation = await this.mjolnir.client.lookupRoomAlias(alias) if (alias) {
roomId = permalink.roomIdOrAlias const roomInformation = await this.mjolnir.client.lookupRoomAlias(alias)
viaServers = roomInformation.residentServers roomId = permalink.roomIdOrAlias
viaServers = roomInformation.residentServers
} else {
roomId = permalink.roomIdOrAlias
viaServers = permalink.viaServers
}
} else { } else {
const roomInfo = await this.mjolnir.client.lookupRoomAlias(permalink.roomIdOrAlias) const roomInfo = await this.mjolnir.client.lookupRoomAlias(permalink.roomIdOrAlias)
roomId = roomInfo.roomId roomId = roomInfo.roomId