Removing completely any analysis of the URL from the front.
Instead, data related to room is sent from the admin, via the pusher.
This commit is contained in:
parent
c85679b42c
commit
968e71cbca
@ -6,12 +6,11 @@
|
||||
import type { Unsubscriber } from "svelte/store";
|
||||
import { playersStore } from "../../Stores/PlayersStore";
|
||||
import { connectionManager } from "../../Connexion/ConnectionManager";
|
||||
import { GameConnexionTypes } from "../../Url/UrlManager";
|
||||
import { get } from "svelte/store";
|
||||
|
||||
let blockActive = true;
|
||||
let reportActive = !blockActive;
|
||||
let anonymous: boolean = false;
|
||||
let disableReport: boolean = false;
|
||||
let userUUID: string | undefined = playersStore.getPlayerById(get(showReportScreenStore).userId)?.userUuid;
|
||||
let userName = "No name";
|
||||
let unsubscriber: Unsubscriber;
|
||||
@ -26,7 +25,7 @@
|
||||
}
|
||||
}
|
||||
});
|
||||
anonymous = connectionManager.getConnexionType === GameConnexionTypes.anonymous;
|
||||
disableReport = !connectionManager.currentRoom?.canReport ?? true;
|
||||
});
|
||||
|
||||
onDestroy(() => {
|
||||
@ -65,7 +64,7 @@
|
||||
<button type="button" class="nes-btn" on:click|preventDefault={close}>X</button>
|
||||
</section>
|
||||
</section>
|
||||
<section class="report-menu-action {anonymous ? 'hidden' : ''}">
|
||||
<section class="report-menu-action {disableReport ? 'hidden' : ''}">
|
||||
<section class="justify-center">
|
||||
<button
|
||||
type="button"
|
||||
|
@ -17,9 +17,7 @@
|
||||
</p>
|
||||
{:else if $limitMapStore}
|
||||
<p>
|
||||
This map is available for 2 days. You can register your domain <a
|
||||
href={registerLink}>here</a
|
||||
>!
|
||||
This map is available for 2 days. You can register your domain <a href={registerLink}>here</a>!
|
||||
</p>
|
||||
{:else}
|
||||
<h2>Warning!</h2>
|
||||
|
@ -154,12 +154,7 @@ class ConnectionManager {
|
||||
)
|
||||
);
|
||||
urlManager.pushRoomIdToUrl(this._currentRoom);
|
||||
} else if (
|
||||
connexionType === GameConnexionTypes.organization ||
|
||||
connexionType === GameConnexionTypes.anonymous ||
|
||||
connexionType === GameConnexionTypes.limit ||
|
||||
connexionType === GameConnexionTypes.empty
|
||||
) {
|
||||
} else if (connexionType === GameConnexionTypes.room || connexionType === GameConnexionTypes.empty) {
|
||||
this.authToken = localUserStore.getAuthToken();
|
||||
|
||||
let roomPath: string;
|
||||
@ -241,12 +236,12 @@ class ConnectionManager {
|
||||
}
|
||||
|
||||
//if limit room active test headband
|
||||
if (connexionType === GameConnexionTypes.limit) {
|
||||
if (this._currentRoom.expireOn !== undefined) {
|
||||
warningContainerStore.activateWarningContainer();
|
||||
limitMapStore.set(true);
|
||||
|
||||
//check time of map
|
||||
if (!urlManager.isActiveLimitRoom) {
|
||||
if (new Date() > this._currentRoom.expireOn) {
|
||||
showLimitRoomModalStore.set(true);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ export class Room {
|
||||
private readonly _search: URLSearchParams;
|
||||
private _contactPage: string | undefined;
|
||||
private _group: string | null = null;
|
||||
private _expireOn: Date | undefined;
|
||||
private _canReport: boolean = false;
|
||||
|
||||
private constructor(private roomUrl: URL) {
|
||||
this.id = roomUrl.pathname;
|
||||
@ -121,6 +123,10 @@ export class Room {
|
||||
data.authenticationMandatory != null ? data.authenticationMandatory : DISABLE_ANONYMOUS;
|
||||
this._iframeAuthentication = data.iframeAuthentication || OPID_LOGIN_SCREEN_PROVIDER;
|
||||
this._contactPage = data.contactPage || CONTACT_URL;
|
||||
if (data.expireOn) {
|
||||
this._expireOn = new Date(data.expireOn);
|
||||
}
|
||||
this._canReport = data.canReport ?? false;
|
||||
return new MapDetail(data.mapUrl, data.textures);
|
||||
} else {
|
||||
throw new Error("Data received by the /map endpoint of the Pusher is not in a valid format.");
|
||||
@ -222,4 +228,12 @@ export class Room {
|
||||
get group(): string | null {
|
||||
return this._group;
|
||||
}
|
||||
|
||||
get expireOn(): Date | undefined {
|
||||
return this._expireOn;
|
||||
}
|
||||
|
||||
get canReport(): boolean {
|
||||
return this._canReport;
|
||||
}
|
||||
}
|
||||
|
@ -2,14 +2,12 @@ import type { Room } from "../Connexion/Room";
|
||||
import { localUserStore } from "../Connexion/LocalUserStore";
|
||||
|
||||
export enum GameConnexionTypes {
|
||||
anonymous = 1,
|
||||
organization,
|
||||
room = 1,
|
||||
register,
|
||||
empty,
|
||||
unknown,
|
||||
jwt,
|
||||
login,
|
||||
limit,
|
||||
}
|
||||
|
||||
//this class is responsible with analysing and editing the game's url
|
||||
@ -20,12 +18,8 @@ class UrlManager {
|
||||
return GameConnexionTypes.login;
|
||||
} else if (url === "/jwt") {
|
||||
return GameConnexionTypes.jwt;
|
||||
} else if (url.includes("*/")) {
|
||||
return GameConnexionTypes.limit;
|
||||
} else if (url.includes("_/")) {
|
||||
return GameConnexionTypes.anonymous;
|
||||
} else if (url.includes("@/")) {
|
||||
return GameConnexionTypes.organization;
|
||||
} else if (url.includes("_/") || url.includes("*/") || url.includes("@/")) {
|
||||
return GameConnexionTypes.room;
|
||||
} else if (url.includes("register/")) {
|
||||
return GameConnexionTypes.register;
|
||||
} else if (url === "/") {
|
||||
@ -58,15 +52,6 @@ class UrlManager {
|
||||
pushStartLayerNameToUrl(startLayerName: string): void {
|
||||
window.location.hash = startLayerName;
|
||||
}
|
||||
|
||||
get isActiveLimitRoom(): boolean {
|
||||
const match = /\*\/(\w+)\/(?:\w+)/.exec(window.location.pathname.toString());
|
||||
const timestamp = match ? Number.parseInt(match[1]) : null;
|
||||
if (!timestamp) {
|
||||
return false;
|
||||
}
|
||||
return new Date().getTime() - 48 * 60 * 60 * 1000 < timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
export const urlManager = new UrlManager();
|
||||
|
@ -20,6 +20,10 @@ export const isMapDetailsData = new tg.IsInterface()
|
||||
})
|
||||
.withOptionalProperties({
|
||||
iframeAuthentication: tg.isNullable(tg.isString),
|
||||
// The date (in ISO 8601 format) at which the room will expire
|
||||
expireOn: tg.isString,
|
||||
// Whether the "report" feature is enabled or not on this room
|
||||
canReport: tg.isBoolean,
|
||||
})
|
||||
.get();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user