From d4f856eb882948bf1e69344f996f51af48bb5b16 Mon Sep 17 00:00:00 2001 From: CEC Date: Tue, 12 Apr 2022 11:12:44 +0200 Subject: [PATCH] Fix prettier --- .../src/Controller/AuthenticateController.ts | 2 +- pusher/src/Controller/BaseHttpController.ts | 2 +- pusher/src/Controller/IoSocketController.ts | 15 +++++++++++++-- pusher/src/Services/AdminApi.ts | 16 ++++++++-------- pusher/src/Services/SocketManager.ts | 18 +++++++++++++++--- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/pusher/src/Controller/AuthenticateController.ts b/pusher/src/Controller/AuthenticateController.ts index eb4af3a1..e1b8c84d 100644 --- a/pusher/src/Controller/AuthenticateController.ts +++ b/pusher/src/Controller/AuthenticateController.ts @@ -318,7 +318,7 @@ export class AuthenticateController extends BaseHttpController { (async () => { const param = await req.json(); - adminApi.setLocale(req.header('accept-language')); + adminApi.setLocale(req.header("accept-language")); //todo: what to do if the organizationMemberToken is already used? const organizationMemberToken: string | null = param.organizationMemberToken; diff --git a/pusher/src/Controller/BaseHttpController.ts b/pusher/src/Controller/BaseHttpController.ts index 17e08e0a..d12345c2 100644 --- a/pusher/src/Controller/BaseHttpController.ts +++ b/pusher/src/Controller/BaseHttpController.ts @@ -31,7 +31,7 @@ export class BaseHttpController { if (axios.isAxiosError(e) && e.response) { res.status(e.response.status); - if(!e.response.data?.code) { + if (!e.response.data?.code) { res.send( "An error occurred: " + e.response.status + diff --git a/pusher/src/Controller/IoSocketController.ts b/pusher/src/Controller/IoSocketController.ts index 1d805102..9bae7595 100644 --- a/pusher/src/Controller/IoSocketController.ts +++ b/pusher/src/Controller/IoSocketController.ts @@ -236,7 +236,7 @@ export class IoSocketController { const websocketExtensions = req.getHeader("sec-websocket-extensions"); const IPAddress = req.getHeader("x-forwarded-for"); - adminApi.setLocale(req.getHeader('accept-language')); + adminApi.setLocale(req.getHeader("accept-language")); const roomId = query.roomId; try { @@ -486,7 +486,18 @@ export class IoSocketController { } else if (ws.reason === "textureInvalid") { socketManager.emitInvalidTextureMessage(ws); } else if (ws.reason === "error") { - socketManager.emitErrorV2Message(ws, ws.error.type, ws.error.code, ws.error.title, ws.error.subtitle, ws.error.details, ws.error.timeToRetry, ws.error.canRetryManual, ws.error.urlToRedirect, ws.error.buttonTitle); + socketManager.emitErrorV2Message( + ws, + ws.error.type, + ws.error.code, + ws.error.title, + ws.error.subtitle, + ws.error.details, + ws.error.timeToRetry, + ws.error.canRetryManual, + ws.error.urlToRedirect, + ws.error.buttonTitle + ); } else { socketManager.emitConnexionErrorMessage(ws, ws.message); } diff --git a/pusher/src/Services/AdminApi.ts b/pusher/src/Services/AdminApi.ts index 8a95fc86..ae12ed14 100644 --- a/pusher/src/Services/AdminApi.ts +++ b/pusher/src/Services/AdminApi.ts @@ -26,8 +26,8 @@ export const isFetchMemberDataByUuidResponse = z.object({ export type FetchMemberDataByUuidResponse = z.infer; class AdminApi { - private locale: string = 'en'; - setLocale(locale: string){ + private locale: string = "en"; + setLocale(locale: string) { //console.info('PUSHER LOCALE SET TO :', locale); this.locale = locale; } @@ -47,7 +47,7 @@ class AdminApi { }; const res = await Axios.get>(ADMIN_API_URL + "/api/map", { - headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale }, + headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale }, params, }); @@ -85,7 +85,7 @@ class AdminApi { ipAddress, characterLayers, }, - headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale }, + headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale }, paramsSerializer: (p) => { return qs.stringify(p, { arrayFormat: "brackets" }); }, @@ -111,7 +111,7 @@ class AdminApi { //todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case. const res = await Axios.get(ADMIN_API_URL + "/api/login-url/" + organizationMemberToken, { params: { playUri }, - headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale }, + headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale }, }); const adminApiData = isAdminApiData.safeParse(res.data); @@ -143,7 +143,7 @@ class AdminApi { reportWorldSlug, }, { - headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale }, + headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale }, } ); } @@ -162,7 +162,7 @@ class AdminApi { encodeURIComponent(userUuid) + "&roomUrl=" + encodeURIComponent(roomUrl), - { headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale } } + { headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale } } ).then((data) => { return data.data; }); @@ -174,7 +174,7 @@ class AdminApi { } return Axios.get(ADMIN_API_URL + "/api/room/sameWorld" + "?roomUrl=" + encodeURIComponent(roomUrl), { - headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale }, + headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale }, }).then((data) => { return data.data; }); diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts index 3b1d8fe5..94369e3d 100644 --- a/pusher/src/Services/SocketManager.ts +++ b/pusher/src/Services/SocketManager.ts @@ -39,7 +39,8 @@ import { WorldFullMessage, PlayerDetailsUpdatedMessage, LockGroupPromptMessage, - InvalidTextureMessage, ErrorV2Message, + InvalidTextureMessage, + ErrorV2Message, } from "../Messages/generated/messages_pb"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY } from "../Enum/EnvironmentVariable"; @@ -643,7 +644,18 @@ export class SocketManager implements ZoneEventListener { client.send(serverToClientMessage.serializeBinary().buffer, true); } - public emitErrorV2Message(client: compressors.WebSocket, type: string, code: string, title: string, subtitle: string, details: string, timeToRetry: number, canRetryManual: boolean, urlToRedirect: string, buttonTitle: string) { + public emitErrorV2Message( + client: compressors.WebSocket, + type: string, + code: string, + title: string, + subtitle: string, + details: string, + timeToRetry: number, + canRetryManual: boolean, + urlToRedirect: string, + buttonTitle: string + ) { const errorMessage = new ErrorV2Message(); errorMessage.setType(type); errorMessage.setCode(code); @@ -659,7 +671,7 @@ export class SocketManager implements ZoneEventListener { serverToClientMessage.setErrorv2message(errorMessage); //if (!client.disconnecting) { - client.send(serverToClientMessage.serializeBinary().buffer, true); + client.send(serverToClientMessage.serializeBinary().buffer, true); //} }