diff --git a/back/src/Controller/IoSocketController.ts b/back/src/Controller/IoSocketController.ts index 75ee3064..cc02d201 100644 --- a/back/src/Controller/IoSocketController.ts +++ b/back/src/Controller/IoSocketController.ts @@ -73,12 +73,12 @@ export class IoSocketController { message: (ws, arrayBuffer, isBinary): void => { try { //TODO refactor message type and data - let message: {event: string, message: {type: string, message: unknown, userUuid: string}} = + const message: {event: string, message: {type: string, message: unknown, userUuid: string}} = JSON.parse(new TextDecoder("utf-8").decode(new Uint8Array(arrayBuffer))); if(message.event === 'user-message') { if (message.message.type === 'ban') { - let messageToEmit = (message.message as {message: string, type: string, userUuid: string}); + const messageToEmit = (message.message as {message: string, type: string, userUuid: string}); socketManager.emitSendUserMessage(messageToEmit); } } diff --git a/back/src/Services/JWTTokenManager.ts b/back/src/Services/JWTTokenManager.ts index 94016b21..f82fa001 100644 --- a/back/src/Services/JWTTokenManager.ts +++ b/back/src/Services/JWTTokenManager.ts @@ -49,12 +49,13 @@ class JWTTokenManager { } //verify user in admin - return adminApi.fetchCheckUserByToken(tokenInterface.userUuid).then(() => { + adminApi.fetchCheckUserByToken(tokenInterface.userUuid).then(() => { resolve(tokenInterface.userUuid); }).catch((err) => { //anonymous user if(err.response && err.response.status && err.response.status === 404){ - return resolve(tokenInterface.userUuid); + resolve(tokenInterface.userUuid); + return; } reject(new Error('Authentication error, invalid token structure. ' + err)); }); diff --git a/back/src/Services/SocketManager.ts b/back/src/Services/SocketManager.ts index a6204941..f32557b0 100644 --- a/back/src/Services/SocketManager.ts +++ b/back/src/Services/SocketManager.ts @@ -674,7 +674,7 @@ class SocketManager { } public emitSendUserMessage(messageToSend: {userUuid: string, message: string, type: string}): void { - let socket = this.searchClientByUuid(messageToSend.userUuid); + const socket = this.searchClientByUuid(messageToSend.userUuid); if(!socket){ throw 'socket was not found'; } diff --git a/front/src/Administration/TypeMessage.ts b/front/src/Administration/TypeMessage.ts index 41b30133..20360fea 100644 --- a/front/src/Administration/TypeMessage.ts +++ b/front/src/Administration/TypeMessage.ts @@ -7,21 +7,21 @@ export class Ban implements TypeMessageInterface { private titleMessage = 'IMPORTANT !'; showMessage(message: string): void { - let div : HTMLDivElement = document.createElement('div'); + const div : HTMLDivElement = document.createElement('div'); div.classList.add('modal-report-user'); div.id = 'report-message-user'; div.style.backgroundColor = '#000000e0'; - let img : HTMLImageElement = document.createElement('img'); + const img : HTMLImageElement = document.createElement('img'); img.src = 'resources/logos/report.svg'; div.appendChild(img); - let title : HTMLParagraphElement = document.createElement('p'); + const title : HTMLParagraphElement = document.createElement('p'); title.id = 'title-report-user'; title.innerText = `${this.titleMessage} (${this.maxNbSecond})`; div.appendChild(title); - let p : HTMLParagraphElement = document.createElement('p'); + const p : HTMLParagraphElement = document.createElement('p'); p.id = 'body-report-user' p.innerText = message; div.appendChild(p); @@ -48,7 +48,7 @@ export class Ban implements TypeMessageInterface { }else{ title.innerText = this.titleMessage; - let imgCancel : HTMLImageElement = document.createElement('img'); + const imgCancel : HTMLImageElement = document.createElement('img'); imgCancel.id = 'cancel-report-user'; imgCancel.src = 'resources/logos/close.svg'; diff --git a/front/src/Administration/UserMessageManager.ts b/front/src/Administration/UserMessageManager.ts index 87395c14..12022b03 100644 --- a/front/src/Administration/UserMessageManager.ts +++ b/front/src/Administration/UserMessageManager.ts @@ -1,36 +1,36 @@ import {RoomConnection} from "../Connexion/RoomConnection"; import * as TypeMessages from "./TypeMessage"; -export interface TypeMessageInterface{ - showMessage(message: string) : void; -}; +export interface TypeMessageInterface { + showMessage(message: string): void; +} export class UserMessageManager { - typeMessages : Map = new Map(); + typeMessages: Map = new Map(); constructor(private Connection: RoomConnection) { - let valueTypeMessageTab = Object.values(TypeMessages); + const valueTypeMessageTab = Object.values(TypeMessages); Object.keys(TypeMessages).forEach((value: string, index: number) => { - let typeMessageInstance : TypeMessageInterface = (new valueTypeMessageTab[index]() as TypeMessageInterface); + const typeMessageInstance: TypeMessageInterface = (new valueTypeMessageTab[index]() as TypeMessageInterface); this.typeMessages.set(value.toLowerCase(), typeMessageInstance); }); this.initialise(); } - initialise(){ + initialise() { //receive signal to show message this.Connection.receiveUserMessage((type: string, message: string) => { this.showMessage(type, message); }); } - showMessage(type: string, message: string){ - let classTypeMessage = this.typeMessages.get(type.toLowerCase()); - if(!classTypeMessage){ + showMessage(type: string, message: string) { + const classTypeMessage = this.typeMessages.get(type.toLowerCase()); + if (!classTypeMessage) { console.error('Message unknown'); return; } classTypeMessage.showMessage(message); } -}; \ No newline at end of file +} \ No newline at end of file