Compute instance in pusher /map endpoint

This commit is contained in:
Alban Bruder 2022-04-12 12:14:25 -04:00 committed by David Négrier
parent 03909f14f7
commit 0f08e3d1b5
3 changed files with 10 additions and 2 deletions

View File

@ -130,6 +130,7 @@ export class Room {
this._canReport = data.canReport ?? false;
this._loadingLogo = data.loadingLogo ?? undefined;
this._loginSceneLogo = data.loginSceneLogo ?? undefined;
this.instance = data.instance;
return new MapDetail(data.mapUrl);
} else {
console.log(data);

View File

@ -13,6 +13,7 @@ export const isMapDetailsData = z.object({
roomSlug: z.nullable(z.string()), // deprecated
contactPage: z.nullable(z.string()),
group: z.nullable(z.string()),
instance: z.string(),
iframeAuthentication: z.optional(z.nullable(z.string())),
// The date (in ISO 8601 format) at which the room will expire

View File

@ -76,6 +76,10 @@ export class MapController extends BaseHttpController {
* type: string|null
* description: The group this room is part of (maps the notion of "world" in WorkAdventure SAAS)
* example: myorg/myworld
* instance:
* type: string
* description: The instance of this map. In a public URL: the second part of the URL (_/[instance]/map.json)
* example: global
* iframeAuthentication:
* type: string|null
* description: The URL of the authentication Iframe
@ -111,14 +115,15 @@ export class MapController extends BaseHttpController {
if (!ADMIN_API_URL) {
const roomUrl = new URL(query.playUri);
const match = /\/_\/[^/]+\/(.+)/.exec(roomUrl.pathname);
const match = /\/_\/([^/]+)\/(.+)/.exec(roomUrl.pathname);
if (!match) {
res.status(404);
res.json({});
return;
}
const mapUrl = roomUrl.protocol + "//" + match[1];
const instance = match[1];
const mapUrl = roomUrl.protocol + "//" + match[2];
res.json({
mapUrl,
@ -128,6 +133,7 @@ export class MapController extends BaseHttpController {
tags: [],
contactPage: null,
authenticationMandatory: DISABLE_ANONYMOUS,
instance,
} as MapDetailsData);
return;