From 31d2f0135bbd6b1918e759048573e03909a1e7b8 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 9 Mar 2020 17:13:50 +0100 Subject: [PATCH 1/2] use alt aliases instead of local ones for room names --- src/models/room.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/room.js b/src/models/room.js index 2b8fadf26d0..ed8c6d12267 100644 --- a/src/models/room.js +++ b/src/models/room.js @@ -1833,7 +1833,7 @@ function calculateRoomName(room, userId, ignoreRoomNameEvent) { let alias = room.getCanonicalAlias(); if (!alias) { - const aliases = room.getAliases(); + const aliases = room.getAltAliases(); if (aliases.length) { alias = aliases[0]; From 950dadc14e4134408bc6d4d73aa919a2e8c58401 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 9 Mar 2020 18:33:20 +0100 Subject: [PATCH 2/2] fix tests --- spec/unit/room.spec.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/spec/unit/room.spec.js b/spec/unit/room.spec.js index fa1c2c64ee8..2f3a5b82999 100644 --- a/spec/unit/room.spec.js +++ b/spec/unit/room.spec.js @@ -617,15 +617,10 @@ describe("Room", function() { }, event: true, })]); }; - const setAliases = function(aliases, stateKey) { - if (!stateKey) { - stateKey = aliases.length - ? aliases[0].split(':').splice(1).join(':') // domain+port - : 'fibble'; - } + const setAltAliases = function(aliases) { room.addLiveEvents([utils.mkEvent({ - type: "m.room.aliases", room: roomId, skey: stateKey, content: { - aliases: aliases, + type: "m.room.canonical_alias", room: roomId, skey: "", content: { + alt_aliases: aliases, }, event: true, })]); }; @@ -862,7 +857,7 @@ describe("Room", function() { "(invite join_rules) rooms if a room name doesn't exist.", function() { const alias = "#room_alias:here"; setJoinRule("invite"); - setAliases([alias, "#another:here"]); + setAltAliases([alias, "#another:here"]); room.recalculate(); const name = room.name; expect(name).toEqual(alias); @@ -872,7 +867,7 @@ describe("Room", function() { "(public join_rules) rooms if a room name doesn't exist.", function() { const alias = "#room_alias:here"; setJoinRule("public"); - setAliases([alias, "#another:here"]); + setAltAliases([alias, "#another:here"]); room.recalculate(); const name = room.name; expect(name).toEqual(alias);