Fix CD
This commit is contained in:
parent
dfa6d2cc66
commit
ba9f9dcbe1
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
});
|
||||
|
@ -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';
|
||||
}
|
||||
|
@ -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';
|
||||
|
||||
|
@ -3,16 +3,16 @@ import * as TypeMessages from "./TypeMessage";
|
||||
|
||||
export interface TypeMessageInterface {
|
||||
showMessage(message: string): void;
|
||||
};
|
||||
}
|
||||
|
||||
export class UserMessageManager {
|
||||
|
||||
typeMessages: Map<string, TypeMessageInterface> = new Map<string, TypeMessageInterface>();
|
||||
|
||||
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();
|
||||
@ -26,11 +26,11 @@ export class UserMessageManager {
|
||||
}
|
||||
|
||||
showMessage(type: string, message: string) {
|
||||
let classTypeMessage = this.typeMessages.get(type.toLowerCase());
|
||||
const classTypeMessage = this.typeMessages.get(type.toLowerCase());
|
||||
if (!classTypeMessage) {
|
||||
console.error('Message unknown');
|
||||
return;
|
||||
}
|
||||
classTypeMessage.showMessage(message);
|
||||
}
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user