Fix CD
This commit is contained in:
parent
dfa6d2cc66
commit
ba9f9dcbe1
@ -73,12 +73,12 @@ export class IoSocketController {
|
|||||||
message: (ws, arrayBuffer, isBinary): void => {
|
message: (ws, arrayBuffer, isBinary): void => {
|
||||||
try {
|
try {
|
||||||
//TODO refactor message type and data
|
//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)));
|
JSON.parse(new TextDecoder("utf-8").decode(new Uint8Array(arrayBuffer)));
|
||||||
|
|
||||||
if(message.event === 'user-message') {
|
if(message.event === 'user-message') {
|
||||||
if (message.message.type === 'ban') {
|
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);
|
socketManager.emitSendUserMessage(messageToEmit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,12 +49,13 @@ class JWTTokenManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//verify user in admin
|
//verify user in admin
|
||||||
return adminApi.fetchCheckUserByToken(tokenInterface.userUuid).then(() => {
|
adminApi.fetchCheckUserByToken(tokenInterface.userUuid).then(() => {
|
||||||
resolve(tokenInterface.userUuid);
|
resolve(tokenInterface.userUuid);
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
//anonymous user
|
//anonymous user
|
||||||
if(err.response && err.response.status && err.response.status === 404){
|
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));
|
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 {
|
public emitSendUserMessage(messageToSend: {userUuid: string, message: string, type: string}): void {
|
||||||
let socket = this.searchClientByUuid(messageToSend.userUuid);
|
const socket = this.searchClientByUuid(messageToSend.userUuid);
|
||||||
if(!socket){
|
if(!socket){
|
||||||
throw 'socket was not found';
|
throw 'socket was not found';
|
||||||
}
|
}
|
||||||
|
@ -7,21 +7,21 @@ export class Ban implements TypeMessageInterface {
|
|||||||
private titleMessage = 'IMPORTANT !';
|
private titleMessage = 'IMPORTANT !';
|
||||||
|
|
||||||
showMessage(message: string): void {
|
showMessage(message: string): void {
|
||||||
let div : HTMLDivElement = document.createElement('div');
|
const div : HTMLDivElement = document.createElement('div');
|
||||||
div.classList.add('modal-report-user');
|
div.classList.add('modal-report-user');
|
||||||
div.id = 'report-message-user';
|
div.id = 'report-message-user';
|
||||||
div.style.backgroundColor = '#000000e0';
|
div.style.backgroundColor = '#000000e0';
|
||||||
|
|
||||||
let img : HTMLImageElement = document.createElement('img');
|
const img : HTMLImageElement = document.createElement('img');
|
||||||
img.src = 'resources/logos/report.svg';
|
img.src = 'resources/logos/report.svg';
|
||||||
div.appendChild(img);
|
div.appendChild(img);
|
||||||
|
|
||||||
let title : HTMLParagraphElement = document.createElement('p');
|
const title : HTMLParagraphElement = document.createElement('p');
|
||||||
title.id = 'title-report-user';
|
title.id = 'title-report-user';
|
||||||
title.innerText = `${this.titleMessage} (${this.maxNbSecond})`;
|
title.innerText = `${this.titleMessage} (${this.maxNbSecond})`;
|
||||||
div.appendChild(title);
|
div.appendChild(title);
|
||||||
|
|
||||||
let p : HTMLParagraphElement = document.createElement('p');
|
const p : HTMLParagraphElement = document.createElement('p');
|
||||||
p.id = 'body-report-user'
|
p.id = 'body-report-user'
|
||||||
p.innerText = message;
|
p.innerText = message;
|
||||||
div.appendChild(p);
|
div.appendChild(p);
|
||||||
@ -48,7 +48,7 @@ export class Ban implements TypeMessageInterface {
|
|||||||
}else{
|
}else{
|
||||||
title.innerText = this.titleMessage;
|
title.innerText = this.titleMessage;
|
||||||
|
|
||||||
let imgCancel : HTMLImageElement = document.createElement('img');
|
const imgCancel : HTMLImageElement = document.createElement('img');
|
||||||
imgCancel.id = 'cancel-report-user';
|
imgCancel.id = 'cancel-report-user';
|
||||||
imgCancel.src = 'resources/logos/close.svg';
|
imgCancel.src = 'resources/logos/close.svg';
|
||||||
|
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
import {RoomConnection} from "../Connexion/RoomConnection";
|
import {RoomConnection} from "../Connexion/RoomConnection";
|
||||||
import * as TypeMessages from "./TypeMessage";
|
import * as TypeMessages from "./TypeMessage";
|
||||||
|
|
||||||
export interface TypeMessageInterface{
|
export interface TypeMessageInterface {
|
||||||
showMessage(message: string) : void;
|
showMessage(message: string): void;
|
||||||
};
|
}
|
||||||
|
|
||||||
export class UserMessageManager {
|
export class UserMessageManager {
|
||||||
|
|
||||||
typeMessages : Map<string, TypeMessageInterface> = new Map<string, TypeMessageInterface>();
|
typeMessages: Map<string, TypeMessageInterface> = new Map<string, TypeMessageInterface>();
|
||||||
|
|
||||||
constructor(private Connection: RoomConnection) {
|
constructor(private Connection: RoomConnection) {
|
||||||
let valueTypeMessageTab = Object.values(TypeMessages);
|
const valueTypeMessageTab = Object.values(TypeMessages);
|
||||||
Object.keys(TypeMessages).forEach((value: string, index: number) => {
|
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.typeMessages.set(value.toLowerCase(), typeMessageInstance);
|
||||||
});
|
});
|
||||||
this.initialise();
|
this.initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
initialise(){
|
initialise() {
|
||||||
//receive signal to show message
|
//receive signal to show message
|
||||||
this.Connection.receiveUserMessage((type: string, message: string) => {
|
this.Connection.receiveUserMessage((type: string, message: string) => {
|
||||||
this.showMessage(type, message);
|
this.showMessage(type, message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
showMessage(type: string, message: string){
|
showMessage(type: string, message: string) {
|
||||||
let classTypeMessage = this.typeMessages.get(type.toLowerCase());
|
const classTypeMessage = this.typeMessages.get(type.toLowerCase());
|
||||||
if(!classTypeMessage){
|
if (!classTypeMessage) {
|
||||||
console.error('Message unknown');
|
console.error('Message unknown');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
classTypeMessage.showMessage(message);
|
classTypeMessage.showMessage(message);
|
||||||
}
|
}
|
||||||
};
|
}
|
Loading…
Reference in New Issue
Block a user