Skip to content

Commit

Permalink
Resolve aliases and get via servers before storing watch list (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay authored Sep 12, 2024
1 parent 9e85463 commit 1c5b49d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/models/PolicyList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,10 +659,19 @@ export class PolicyListManager {
if (!permalink.roomIdOrAlias) return null;

let roomId: string;
let viaServers;
let viaServers: string[];
if (permalink.roomIdOrAlias.startsWith("!")) {
roomId = permalink.roomIdOrAlias
viaServers = permalink.viaServers
// 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)
if (alias) {
const roomInformation = await this.mjolnir.client.lookupRoomAlias(alias)
roomId = permalink.roomIdOrAlias
viaServers = roomInformation.residentServers
} else {
roomId = permalink.roomIdOrAlias
viaServers = permalink.viaServers
}
} else {
const roomInfo = await this.mjolnir.client.lookupRoomAlias(permalink.roomIdOrAlias)
roomId = roomInfo.roomId
Expand All @@ -682,7 +691,8 @@ export class PolicyListManager {
return null;
}

const list = await this.addPolicyList(roomId, roomRef);
const newRef = Permalinks.forRoom(roomId, viaServers)
const list = await this.addPolicyList(roomId, newRef);

await this.storeWatchedPolicyLists();

Expand Down

0 comments on commit 1c5b49d

Please sign in to comment.