Skip to content

Commit 9b54df7

Browse files
authored
Don't consider alt_aliases when calculating room name (#2094)
1 parent 5da562f commit 9b54df7

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

spec/unit/room.spec.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,11 @@ describe("Room", function() {
622622
}, event: true,
623623
})]);
624624
};
625+
const setAlias = function(alias) {
626+
room.addLiveEvents([utils.mkEvent({
627+
type: "m.room.canonical_alias", room: roomId, skey: "", content: { alias }, event: true,
628+
})]);
629+
};
625630
const setRoomName = function(name) {
626631
room.addLiveEvents([utils.mkEvent({
627632
type: "m.room.name", room: roomId, user: userA, content: {
@@ -857,7 +862,7 @@ describe("Room", function() {
857862
"(invite join_rules) rooms if a room name doesn't exist.", function() {
858863
const alias = "#room_alias:here";
859864
setJoinRule("invite");
860-
setAltAliases([alias, "#another:here"]);
865+
setAlias(alias);
861866
room.recalculate();
862867
const name = room.name;
863868
expect(name).toEqual(alias);
@@ -867,12 +872,20 @@ describe("Room", function() {
867872
"(public join_rules) rooms if a room name doesn't exist.", function() {
868873
const alias = "#room_alias:here";
869874
setJoinRule("public");
870-
setAltAliases([alias, "#another:here"]);
875+
setAlias(alias);
871876
room.recalculate();
872877
const name = room.name;
873878
expect(name).toEqual(alias);
874879
});
875880

881+
it("should not show alt aliases if a room name does not exist", () => {
882+
const alias = "#room_alias:here";
883+
setAltAliases([alias, "#another:here"]);
884+
room.recalculate();
885+
const name = room.name;
886+
expect(name).not.toEqual(alias);
887+
});
888+
876889
it("should show the room name if one exists for private " +
877890
"(invite join_rules) rooms.", function() {
878891
const roomName = "A mighty name indeed";

src/models/room.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2205,15 +2205,7 @@ export class Room extends EventEmitter {
22052205
}
22062206
}
22072207

2208-
let alias = this.getCanonicalAlias();
2209-
2210-
if (!alias) {
2211-
const aliases = this.getAltAliases();
2212-
2213-
if (aliases.length) {
2214-
alias = aliases[0];
2215-
}
2216-
}
2208+
const alias = this.getCanonicalAlias();
22172209
if (alias) {
22182210
return alias;
22192211
}

0 commit comments

Comments
 (0)