Knock support

Also, fix token refresh functionality
This commit is contained in:
N-Pex 2025-05-28 12:29:04 +02:00
parent cfabd8be08
commit e8f04d79c9
11 changed files with 310 additions and 75 deletions

View file

@ -31,7 +31,7 @@ const routes = [
{
path: '/info',
name: 'RoomInfo',
component: defineAsyncComponent(() => import('../components/RoomInfo.vue')),
component: () => import('../components/RoomInfo.vue'),
props: true,
meta: {
title: 'Info',
@ -85,7 +85,13 @@ const routes = [
{
path: '/join/:join(join/)?:roomId?',
name: 'Join',
component: Join
component: Join,
props: route => {
return {
roomNeedsKnock: (route.query.knock ? true : false),
roomDisplayName: route.query.roomName
}
}
},
{
path: '/user/:userId?',
@ -202,7 +208,7 @@ router.beforeEach((to, from, next) => {
}
});
router.getRoomLink = function (alias, roomId, roomName, mode, autojoin) {
router.getRoomLink = function (alias, roomId, roomName, mode, autojoin, knock) {
let params = {};
if ((!alias || roomName.replace(/\s/g, "").toLowerCase() !== util.getRoomNameFromAlias(alias)) && roomName) {
// There is no longer a correlation between alias and room name, probably because room name has
@ -213,14 +219,17 @@ router.getRoomLink = function (alias, roomId, roomName, mode, autojoin) {
// Optional mode given, append as "m" query param
params["m"] = mode;
}
if (knock) {
params["knock"] = "1";
}
const autoJoinSegment = autojoin ? "join/" : "";
let queryString = "";
if (Object.entries(params).length > 0) {
const queryString = Object.entries(params)
queryString = "?" + Object.entries(params)
.map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
.join('&')
return window.location.origin + window.location.pathname + "?" + queryString + "#/room/" + autoJoinSegment + encodeURIComponent(util.sanitizeRoomId(alias || roomId));
}
return window.location.origin + window.location.pathname + "#/room/" + autoJoinSegment + encodeURIComponent(util.sanitizeRoomId(alias || roomId));
return window.location.origin + window.location.pathname + "#/room/" + autoJoinSegment + encodeURIComponent(util.sanitizeRoomId(alias || roomId)) + queryString;
}
router.getDMLink = function (user, config) {