diff --git a/front/src/Components/UI/ErrorScreen.svelte b/front/src/Components/UI/ErrorScreen.svelte index 71b33456..bac59594 100644 --- a/front/src/Components/UI/ErrorScreen.svelte +++ b/front/src/Components/UI/ErrorScreen.svelte @@ -8,17 +8,10 @@ import logoImg from "../images/logo-min-white.png"; let logo = gameManager?.currentStartedRoom?.loginSceneLogo ?? logoImg; import reload from "../images/reload.png"; - import external from "../images/external-link.png"; - import { connectionManager } from "../../Connexion/ConnectionManager"; - let errorScreen = get(errorScreenStore); function click() { - if (errorScreen.urlToRedirect) { - if (errorScreen.urlToRedirect === "/login") void connectionManager.logout(); - else window.location.assign(errorScreen.urlToRedirect); - } else if (errorScreen.type === "redirect" && window.history.length > 2) history.back(); - else window.location.reload(); + window.location.reload(); } let details = errorScreen.details; let timeVar = errorScreen.timeToRetry ?? 0; @@ -31,7 +24,7 @@ onDestroy(() => clearInterval(interval)); } - $: detailsStylized = details.replace("{time}", `${timeVar / 1000}`); + $: detailsStylized = (details ?? "").replace("{time}", `${timeVar / 1000}`);
@@ -44,9 +37,9 @@

{detailsStylized}{#if $errorScreenStore.type === "retry"}

{/if}

- {#if ($errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual) || ($errorScreenStore.type === "unauthorized" && $errorScreenStore.urlToRedirect && $errorScreenStore.buttonTitle) || ($errorScreenStore.type === "redirect" && (window.history.length > 2 || $errorScreenStore.urlToRedirect))} + {#if $errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual} {/if} diff --git a/front/src/Components/images/external-link.png b/front/src/Components/images/external-link.png deleted file mode 100644 index 52fca4ed..00000000 Binary files a/front/src/Components/images/external-link.png and /dev/null differ diff --git a/front/src/Phaser/Login/EntryScene.ts b/front/src/Phaser/Login/EntryScene.ts index 02579af1..dce7216d 100644 --- a/front/src/Phaser/Login/EntryScene.ts +++ b/front/src/Phaser/Login/EntryScene.ts @@ -49,9 +49,9 @@ export class EntryScene extends Scene { .catch((err) => { const errorType = isErrorApiData.safeParse(err?.response?.data); if (errorType.success) { - if (errorType.data.type === 'unauthorized') { + if (errorType.data.type === "unauthorized") { void connectionManager.logout(); - } else if (errorType.data.type === 'redirect') { + } else if (errorType.data.type === "redirect") { window.location.assign(errorType.data.urlToRedirect); } else errorScreenStore.setError(err?.response?.data); } else { diff --git a/front/src/Stores/ErrorScreenStore.ts b/front/src/Stores/ErrorScreenStore.ts index a9081b21..564afb92 100644 --- a/front/src/Stores/ErrorScreenStore.ts +++ b/front/src/Stores/ErrorScreenStore.ts @@ -10,7 +10,7 @@ function createErrorScreenStore() { return { subscribe, setError: (e: ErrorScreenMessage): void => { - set(e) + set(e); }, }; } diff --git a/messages/JsonMessages/ErrorApiData.ts b/messages/JsonMessages/ErrorApiData.ts index e9ea4e55..0fbf3db7 100644 --- a/messages/JsonMessages/ErrorApiData.ts +++ b/messages/JsonMessages/ErrorApiData.ts @@ -43,9 +43,4 @@ export const isErrorApiData = z.discriminatedUnion("type", [ isErrorApiUnauthorizedData, ]); -export type ErrorApiErrorData = z.infer; -export type ErrorApiRetryData = z.infer; -export type ErrorApiRedirectData = z.infer; -export type ErrorApiUnauthorizedData = z.infer; - export type ErrorApiData = z.infer; diff --git a/pusher/package.json b/pusher/package.json index 22f6960e..cbd5375e 100644 --- a/pusher/package.json +++ b/pusher/package.json @@ -40,6 +40,7 @@ }, "homepage": "https://github.com/thecodingmachine/workadventure#readme", "dependencies": { + "@anatine/zod-openapi": "^1.3.0", "axios": "^0.21.2", "circular-json": "^0.5.9", "debug": "^4.3.1", @@ -48,6 +49,7 @@ "hyper-express": "^5.8.1", "jsonwebtoken": "^8.5.1", "mkdirp": "^1.0.4", + "openapi3-ts": "^2.0.2", "openid-client": "^4.7.4", "prom-client": "^12.0.0", "qs": "^6.10.3", diff --git a/pusher/src/Controller/IoSocketController.ts b/pusher/src/Controller/IoSocketController.ts index 3912d951..d985261a 100644 --- a/pusher/src/Controller/IoSocketController.ts +++ b/pusher/src/Controller/IoSocketController.ts @@ -247,7 +247,6 @@ export class IoSocketController { const IPAddress = req.getHeader("x-forwarded-for"); const locale = req.getHeader("accept-language"); - const roomId = query.roomId; try { if (typeof roomId !== "string") { @@ -345,7 +344,7 @@ export class IoSocketController { reason: null, status: 500, message: err?.response?.data, - roomId: roomId + roomId: roomId, } as UpgradeFailedData, websocketKey, websocketProtocol, diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index 1476e89a..5bbfe32c 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -59,9 +59,10 @@ import { ErrorApiData, isErrorApiErrorData, isErrorApiRedirectData, - isErrorApiRetryData, isErrorApiUnauthorizedData + isErrorApiRetryData, + isErrorApiUnauthorizedData, } from "../Messages/JsonMessages/ErrorApiData"; -import {BoolValue, Int32Value, StringValue} from "google-protobuf/google/protobuf/wrappers_pb"; +import { BoolValue, Int32Value, StringValue } from "google-protobuf/google/protobuf/wrappers_pb"; const debug = Debug("socket"); @@ -681,20 +682,22 @@ export class SocketManager implements ZoneEventListener { public emitErrorScreenMessage(client: compressors.WebSocket, errorApi: ErrorApiData) { const errorMessage = new ErrorScreenMessage(); errorMessage.setType(errorApi.type); - if(errorApi.type == 'retry' || errorApi.type == 'error'){ + if (errorApi.type == "retry" || errorApi.type == "error") { errorMessage.setCode(new StringValue().setValue(errorApi.code)); errorMessage.setTitle(new StringValue().setValue(errorApi.title)); errorMessage.setSubtitle(new StringValue().setValue(errorApi.subtitle)); errorMessage.setDetails(new StringValue().setValue(errorApi.details)); errorMessage.setImage(new StringValue().setValue(errorApi.image)); } - if(errorApi.type == 'retry') { + if (errorApi.type == "retry") { if (errorApi.buttonTitle) errorMessage.setButtontitle(new StringValue().setValue(errorApi.buttonTitle)); - if (errorApi.canRetryManual !== undefined) errorMessage.setCanretrymanual(new BoolValue().setValue(errorApi.canRetryManual)); - if (errorApi.timeToRetry) errorMessage.setTimetoretry(new Int32Value().setValue(Number(errorApi.timeToRetry))); + if (errorApi.canRetryManual !== undefined) + errorMessage.setCanretrymanual(new BoolValue().setValue(errorApi.canRetryManual)); + if (errorApi.timeToRetry) + errorMessage.setTimetoretry(new Int32Value().setValue(Number(errorApi.timeToRetry))); } - if(errorApi.type == 'redirect' && errorApi.urlToRedirect) errorMessage.setUrltoredirect(new StringValue().setValue(errorApi.urlToRedirect)); - + if (errorApi.type == "redirect" && errorApi.urlToRedirect) + errorMessage.setUrltoredirect(new StringValue().setValue(errorApi.urlToRedirect)); const serverToClientMessage = new ServerToClientMessage(); serverToClientMessage.setErrorscreenmessage(errorMessage);