Fix prettier

This commit is contained in:
CEC 2022-04-12 11:12:44 +02:00
parent 748baa9bbc
commit 0b579418ad
5 changed files with 38 additions and 15 deletions

View File

@ -318,7 +318,7 @@ export class AuthenticateController extends BaseHttpController {
(async () => { (async () => {
const param = await req.json(); 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? //todo: what to do if the organizationMemberToken is already used?
const organizationMemberToken: string | null = param.organizationMemberToken; const organizationMemberToken: string | null = param.organizationMemberToken;

View File

@ -31,7 +31,7 @@ export class BaseHttpController {
if (axios.isAxiosError(e) && e.response) { if (axios.isAxiosError(e) && e.response) {
res.status(e.response.status); res.status(e.response.status);
if(!e.response.data?.code) { if (!e.response.data?.code) {
res.send( res.send(
"An error occurred: " + "An error occurred: " +
e.response.status + e.response.status +

View File

@ -231,7 +231,7 @@ export class IoSocketController {
const websocketExtensions = req.getHeader("sec-websocket-extensions"); const websocketExtensions = req.getHeader("sec-websocket-extensions");
const IPAddress = req.getHeader("x-forwarded-for"); const IPAddress = req.getHeader("x-forwarded-for");
adminApi.setLocale(req.getHeader('accept-language')); adminApi.setLocale(req.getHeader("accept-language"));
const roomId = query.roomId; const roomId = query.roomId;
try { try {
@ -481,7 +481,18 @@ export class IoSocketController {
} else if (ws.reason === "textureInvalid") { } else if (ws.reason === "textureInvalid") {
socketManager.emitInvalidTextureMessage(ws); socketManager.emitInvalidTextureMessage(ws);
} else if (ws.reason === "error") { } 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 { } else {
socketManager.emitConnexionErrorMessage(ws, ws.message); socketManager.emitConnexionErrorMessage(ws, ws.message);
} }

View File

@ -31,8 +31,8 @@ const isFetchMemberDataByUuidResponse = new tg.IsInterface()
export type FetchMemberDataByUuidResponse = tg.GuardedType<typeof isFetchMemberDataByUuidResponse>; export type FetchMemberDataByUuidResponse = tg.GuardedType<typeof isFetchMemberDataByUuidResponse>;
class AdminApi { class AdminApi {
private locale: string = 'en'; private locale: string = "en";
setLocale(locale: string){ setLocale(locale: string) {
//console.info('PUSHER LOCALE SET TO :', locale); //console.info('PUSHER LOCALE SET TO :', locale);
this.locale = locale; this.locale = locale;
} }
@ -52,7 +52,7 @@ class AdminApi {
}; };
const res = await Axios.get<unknown, AxiosResponse<unknown>>(ADMIN_API_URL + "/api/map", { const res = await Axios.get<unknown, AxiosResponse<unknown>>(ADMIN_API_URL + "/api/map", {
headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale }, headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale },
params, params,
}); });
if (!isMapDetailsData(res.data) && !isRoomRedirect(res.data)) { if (!isMapDetailsData(res.data) && !isRoomRedirect(res.data)) {
@ -80,7 +80,7 @@ class AdminApi {
ipAddress, ipAddress,
characterLayers, characterLayers,
}, },
headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale }, headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale },
paramsSerializer: (p) => { paramsSerializer: (p) => {
return qs.stringify(p, { arrayFormat: "brackets" }); return qs.stringify(p, { arrayFormat: "brackets" });
}, },
@ -101,7 +101,7 @@ class AdminApi {
//todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case. //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, { const res = await Axios.get(ADMIN_API_URL + "/api/login-url/" + organizationMemberToken, {
params: { playUri }, params: { playUri },
headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale }, headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale },
}); });
if (!isAdminApiData(res.data)) { if (!isAdminApiData(res.data)) {
console.error("Message received from /api/login-url is not in the expected format. Message: ", res.data); console.error("Message received from /api/login-url is not in the expected format. Message: ", res.data);
@ -128,7 +128,7 @@ class AdminApi {
reportWorldSlug, reportWorldSlug,
}, },
{ {
headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale }, headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale },
} }
); );
} }
@ -147,7 +147,7 @@ class AdminApi {
encodeURIComponent(userUuid) + encodeURIComponent(userUuid) +
"&roomUrl=" + "&roomUrl=" +
encodeURIComponent(roomUrl), encodeURIComponent(roomUrl),
{ headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale } } { headers: { Authorization: `${ADMIN_API_TOKEN}`, "Accept-Language": this.locale } }
).then((data) => { ).then((data) => {
return data.data; return data.data;
}); });
@ -159,7 +159,7 @@ class AdminApi {
} }
return Axios.get(ADMIN_API_URL + "/api/room/sameWorld" + "?roomUrl=" + encodeURIComponent(roomUrl), { 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) => { }).then((data) => {
return data.data; return data.data;
}); });

View File

@ -39,7 +39,8 @@ import {
WorldFullMessage, WorldFullMessage,
PlayerDetailsUpdatedMessage, PlayerDetailsUpdatedMessage,
LockGroupPromptMessage, LockGroupPromptMessage,
InvalidTextureMessage, ErrorV2Message, InvalidTextureMessage,
ErrorV2Message,
} from "../Messages/generated/messages_pb"; } from "../Messages/generated/messages_pb";
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY } from "../Enum/EnvironmentVariable"; import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY } from "../Enum/EnvironmentVariable";
@ -644,7 +645,18 @@ export class SocketManager implements ZoneEventListener {
client.send(serverToClientMessage.serializeBinary().buffer, true); 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(); const errorMessage = new ErrorV2Message();
errorMessage.setType(type); errorMessage.setType(type);
errorMessage.setCode(code); errorMessage.setCode(code);