Migrating away from the notion of public/private URL in WorkAdventure Github repository
The notion of public/private repositories (with /_/ and /@/ URLs) is specific to the SAAS version of WorkAdventure. It would be better to avoid leaking the organization/world/room structure of the private SAAS URLs inside the WorkAdventure Github project. Rather than sending http://admin_host/api/map?organizationSlug=...&worldSlug=...&roomSlug=...., we are now sending /api/map&playUri=... where playUri is the full URL of the current game. This allows the backend to act as a complete router. The front (and the pusher) will be able to completely ignore the specifics of URL building (with /@/ and /_/ URLs, etc...) Those details will live only in the admin server, which is way cleaner (and way more powerful).
This commit is contained in:
parent
f2ca7b2b16
commit
c9fa9b9a92
20 changed files with 292 additions and 343 deletions
|
@ -3,9 +3,7 @@ import Axios from "axios";
|
|||
import { GameRoomPolicyTypes } from "_Model/PusherRoom";
|
||||
|
||||
export interface AdminApiData {
|
||||
organizationSlug: string;
|
||||
worldSlug: string;
|
||||
roomSlug: string;
|
||||
roomUrl: string;
|
||||
mapUrlStart: string;
|
||||
tags: string[];
|
||||
policy_type: number;
|
||||
|
@ -43,24 +41,15 @@ export interface FetchMemberDataByUuidResponse {
|
|||
}
|
||||
|
||||
class AdminApi {
|
||||
async fetchMapDetails(
|
||||
organizationSlug: string,
|
||||
worldSlug: string,
|
||||
roomSlug: string | undefined
|
||||
): Promise<MapDetailsData> {
|
||||
async fetchMapDetails(playUri: string): Promise<MapDetailsData> {
|
||||
if (!ADMIN_API_URL) {
|
||||
return Promise.reject(new Error("No admin backoffice set!"));
|
||||
}
|
||||
|
||||
const params: { organizationSlug: string; worldSlug: string; roomSlug?: string } = {
|
||||
organizationSlug,
|
||||
worldSlug,
|
||||
const params: { playUri: string } = {
|
||||
playUri,
|
||||
};
|
||||
|
||||
if (roomSlug) {
|
||||
params.roomSlug = roomSlug;
|
||||
}
|
||||
|
||||
const res = await Axios.get(ADMIN_API_URL + "/api/map", {
|
||||
headers: { Authorization: `${ADMIN_API_TOKEN}` },
|
||||
params,
|
||||
|
@ -121,26 +110,20 @@ class AdminApi {
|
|||
);
|
||||
}
|
||||
|
||||
async verifyBanUser(
|
||||
organizationMemberToken: string,
|
||||
ipAddress: string,
|
||||
organization: string,
|
||||
world: string
|
||||
): Promise<AdminBannedData> {
|
||||
async verifyBanUser(userUuid: string, ipAddress: string, roomUrl: string): Promise<AdminBannedData> {
|
||||
if (!ADMIN_API_URL) {
|
||||
return Promise.reject(new Error("No admin backoffice set!"));
|
||||
}
|
||||
//todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case.
|
||||
return Axios.get(
|
||||
ADMIN_API_URL +
|
||||
"/api/check-moderate-user/" +
|
||||
organization +
|
||||
"/" +
|
||||
world +
|
||||
"/api/ban" +
|
||||
"?ipAddress=" +
|
||||
ipAddress +
|
||||
encodeURIComponent(ipAddress) +
|
||||
"&token=" +
|
||||
organizationMemberToken,
|
||||
encodeURIComponent(userUuid) +
|
||||
"&roomUrl=" +
|
||||
encodeURIComponent(roomUrl),
|
||||
{ headers: { Authorization: `${ADMIN_API_TOKEN}` } }
|
||||
).then((data) => {
|
||||
return data.data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue