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

Revert "room name should only take canonical alias into account" #738

Merged
merged 1 commit into from
Sep 20, 2018
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions spec/unit/room.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -863,24 +863,24 @@ describe("Room", function() {
expect(name.indexOf(userB)).toNotEqual(-1, name);
});

it("should not show the room alias if one exists for private " +
it("should show the room alias if one exists for private " +
"(invite join_rules) rooms if a room name doesn't exist.", function() {
const alias = "#room_alias:here";
setJoinRule("invite");
setAliases([alias, "#another:one"]);
room.recalculate();
const name = room.name;
expect(name).toEqual("Empty room");
expect(name).toEqual(alias);
});

it("should not show the room alias if one exists for public " +
it("should show the room alias if one exists for public " +
"(public join_rules) rooms if a room name doesn't exist.", function() {
const alias = "#room_alias:here";
setJoinRule("public");
setAliases([alias, "#another:one"]);
room.recalculate();
const name = room.name;
expect(name).toEqual("Empty room");
expect(name).toEqual(alias);
});

it("should show the room name if one exists for private " +
Expand Down
10 changes: 9 additions & 1 deletion src/models/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -1525,7 +1525,15 @@ function calculateRoomName(room, userId, ignoreRoomNameEvent) {
}
}

const alias = room.getCanonicalAlias();
let alias = room.getCanonicalAlias();

if (!alias) {
const aliases = room.getAliases();

if (aliases.length) {
alias = aliases[0];
}
}
if (alias) {
return alias;
}
Expand Down