Merge branch 'develop' of github.com:thecodingmachine/workadventure into scripting_api_room_metadata
This commit is contained in:
commit
5c7ea7b258
66 changed files with 1296 additions and 967 deletions
|
@ -39,9 +39,7 @@ export class AuthenticateController extends BaseController {
|
|||
if (typeof organizationMemberToken != "string") throw new Error("No organization token");
|
||||
const data = await adminApi.fetchMemberDataByToken(organizationMemberToken);
|
||||
const userUuid = data.userUuid;
|
||||
const organizationSlug = data.organizationSlug;
|
||||
const worldSlug = data.worldSlug;
|
||||
const roomSlug = data.roomSlug;
|
||||
const roomUrl = data.roomUrl;
|
||||
const mapUrlStart = data.mapUrlStart;
|
||||
const textures = data.textures;
|
||||
|
||||
|
@ -52,9 +50,7 @@ export class AuthenticateController extends BaseController {
|
|||
JSON.stringify({
|
||||
authToken,
|
||||
userUuid,
|
||||
organizationSlug,
|
||||
worldSlug,
|
||||
roomSlug,
|
||||
roomUrl,
|
||||
mapUrlStart,
|
||||
organizationMemberToken,
|
||||
textures,
|
||||
|
|
|
@ -16,19 +16,21 @@ import {
|
|||
SendUserMessage,
|
||||
ServerToClientMessage,
|
||||
CompanionMessage,
|
||||
EmotePromptMessage, VariableMessage,
|
||||
EmotePromptMessage,
|
||||
VariableMessage,
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import { UserMovesMessage } from "../Messages/generated/messages_pb";
|
||||
import { TemplatedApp } from "uWebSockets.js";
|
||||
import { parse } from "query-string";
|
||||
import { jwtTokenManager } from "../Services/JWTTokenManager";
|
||||
import { adminApi, CharacterTexture, FetchMemberDataByUuidResponse } from "../Services/AdminApi";
|
||||
import { adminApi, FetchMemberDataByUuidResponse } from "../Services/AdminApi";
|
||||
import { SocketManager, socketManager } from "../Services/SocketManager";
|
||||
import { emitInBatch } from "../Services/IoSocketHelpers";
|
||||
import { ADMIN_API_TOKEN, ADMIN_API_URL, SOCKET_IDLE_TIMER } from "../Enum/EnvironmentVariable";
|
||||
import { Zone } from "_Model/Zone";
|
||||
import { ExAdminSocketInterface } from "_Model/Websocket/ExAdminSocketInterface";
|
||||
import { v4 } from "uuid";
|
||||
import { CharacterTexture } from "../Services/AdminApi/CharacterTexture";
|
||||
|
||||
export class IoSocketController {
|
||||
private nextUserId: number = 1;
|
||||
|
@ -221,14 +223,12 @@ export class IoSocketController {
|
|||
memberVisitCardUrl = userData.visitCardUrl;
|
||||
memberTextures = userData.textures;
|
||||
if (
|
||||
!room.public &&
|
||||
room.policyType === GameRoomPolicyTypes.USE_TAGS_POLICY &&
|
||||
(userData.anonymous === true || !room.canAccess(memberTags))
|
||||
) {
|
||||
throw new Error("Insufficient privileges to access this room");
|
||||
}
|
||||
if (
|
||||
!room.public &&
|
||||
room.policyType === GameRoomPolicyTypes.MEMBERS_ONLY_POLICY &&
|
||||
userData.anonymous === true
|
||||
) {
|
||||
|
|
|
@ -2,6 +2,9 @@ import { HttpRequest, HttpResponse, TemplatedApp } from "uWebSockets.js";
|
|||
import { BaseController } from "./BaseController";
|
||||
import { parse } from "query-string";
|
||||
import { adminApi } from "../Services/AdminApi";
|
||||
import { ADMIN_API_URL } from "../Enum/EnvironmentVariable";
|
||||
import { GameRoomPolicyTypes } from "../Model/PusherRoom";
|
||||
import { MapDetailsData } from "../Services/AdminApi/MapDetailsData";
|
||||
|
||||
export class MapController extends BaseController {
|
||||
constructor(private App: TemplatedApp) {
|
||||
|
@ -25,35 +28,46 @@ export class MapController extends BaseController {
|
|||
|
||||
const query = parse(req.getQuery());
|
||||
|
||||
if (typeof query.organizationSlug !== "string") {
|
||||
console.error("Expected organizationSlug parameter");
|
||||
if (typeof query.playUri !== "string") {
|
||||
console.error("Expected playUri parameter in /map endpoint");
|
||||
res.writeStatus("400 Bad request");
|
||||
this.addCorsHeaders(res);
|
||||
res.end("Expected organizationSlug parameter");
|
||||
res.end("Expected playUri parameter");
|
||||
return;
|
||||
}
|
||||
if (typeof query.worldSlug !== "string") {
|
||||
console.error("Expected worldSlug parameter");
|
||||
res.writeStatus("400 Bad request");
|
||||
|
||||
// If no admin URL is set, let's react on '/_/[instance]/[map url]' URLs
|
||||
if (!ADMIN_API_URL) {
|
||||
const roomUrl = new URL(query.playUri);
|
||||
|
||||
const match = /\/_\/[^/]+\/(.+)/.exec(roomUrl.pathname);
|
||||
if (!match) {
|
||||
res.writeStatus("404 Not Found");
|
||||
this.addCorsHeaders(res);
|
||||
res.end(JSON.stringify({}));
|
||||
return;
|
||||
}
|
||||
|
||||
const mapUrl = roomUrl.protocol + "//" + match[1];
|
||||
|
||||
res.writeStatus("200 OK");
|
||||
this.addCorsHeaders(res);
|
||||
res.end("Expected worldSlug parameter");
|
||||
return;
|
||||
}
|
||||
if (typeof query.roomSlug !== "string" && query.roomSlug !== undefined) {
|
||||
console.error("Expected only one roomSlug parameter");
|
||||
res.writeStatus("400 Bad request");
|
||||
this.addCorsHeaders(res);
|
||||
res.end("Expected only one roomSlug parameter");
|
||||
res.end(
|
||||
JSON.stringify({
|
||||
mapUrl,
|
||||
policy_type: GameRoomPolicyTypes.ANONYMOUS_POLICY,
|
||||
roomSlug: "", // Deprecated
|
||||
tags: [],
|
||||
textures: [],
|
||||
} as MapDetailsData)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const mapDetails = await adminApi.fetchMapDetails(
|
||||
query.organizationSlug as string,
|
||||
query.worldSlug as string,
|
||||
query.roomSlug as string | undefined
|
||||
);
|
||||
const mapDetails = await adminApi.fetchMapDetails(query.playUri as string);
|
||||
|
||||
res.writeStatus("200 OK");
|
||||
this.addCorsHeaders(res);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue