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

@ -15,8 +15,16 @@ export default {
Vue.set(config, key, json[key]);
}
// If default server is not set, default to current server address
if (!json.defaultServer) {
Vue.set(config, "defaultServer", defaultServerFromLocation);
if (!json.defaultBaseUrl) {
if (json.defaultServer) {
// TODO - Only to migrate old values (defaultServer was renamed defaultBaseUrl), can be removed later...
Vue.set(config, "defaultBaseUrl", defaultServerFromLocation);
} else {
Vue.set(config, "defaultBaseUrl", json.defaultServer);
}
}
if (json.useFullyQualifiedDMLinks == undefined) {
Vue.set(config, "useFullyQualifiedDMLinks", true); // Default to true
}
Vue.set(config, "loaded", true);
@ -26,6 +34,24 @@ export default {
}
return config;
});
/**
* If there is an explicit mapping for this MX domain in the config file, return the endpoint URL that it maps to.
* @param {*} domain
* @returns
*/
config.getMatrixDomainPartMapping = (domain) => {
console.log("Get domain endpoint mapping for", domain);
if (config.matrixDomainPartMapping && config.matrixDomainPartMapping[domain]) {
const mapping = config.matrixDomainPartMapping[domain];
if (Array.isArray(mapping)) {
return mapping[0]; //TODO - Use the first one for now, but maybe rotate somehow?
}
return mapping;
}
return undefined;
}
Vue.prototype.$config = config;
}
}