Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve aliases and get via servers before storing watch list #518

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading