Improved BaseURL and DM link handling

This commit is contained in:
N Pex 2023-12-01 08:20:03 +00:00
parent b14749c28f
commit dd70e4a576
9 changed files with 373 additions and 322 deletions

View file

@ -130,9 +130,9 @@ router.beforeEach((to, from, next) => {
if (roomId && !roomId.startsWith("@")) {
// Not a full username. Assume local name on this server.
return router.app.$config.promise.then((config) => {
const user = new User(config.defaultServer, roomId, "");
user.normalize();
roomId = "@" + roomId + ":" + User.serverDomain(user.home_server);
const domain = config.homeServer;
if (!domain) throw new Error("No domain part for user invite!");
roomId = "@" + roomId + ":" + domain;
router.app.$matrix.setCurrentRoomId(roomId);
}).catch(err => console.error(err)).finally(() => next());
} else {
@ -186,7 +186,7 @@ router.getRoomLink = function (alias, roomId, roomName, mode) {
router.getDMLink = function (user, config) {
let userId = user.user_id;
if (user.home_server === config.defaultServer) {
if (User.domainPart(userId) === config.homeServer && !config.useFullyQualifiedDMLinks) {
// Using default server, don't include it in the link
userId = User.localPart(user.user_id);
}