Finish report in admin
This commit is contained in:
parent
aeced0c648
commit
3c2f134e4e
@ -2,7 +2,14 @@ import * as http from "http";
|
|||||||
import {MessageUserPosition, Point} from "../Model/Websocket/MessageUserPosition"; //TODO fix import by "_Model/.."
|
import {MessageUserPosition, Point} from "../Model/Websocket/MessageUserPosition"; //TODO fix import by "_Model/.."
|
||||||
import {ExSocketInterface} from "../Model/Websocket/ExSocketInterface"; //TODO fix import by "_Model/.."
|
import {ExSocketInterface} from "../Model/Websocket/ExSocketInterface"; //TODO fix import by "_Model/.."
|
||||||
import Jwt, {JsonWebTokenError} from "jsonwebtoken";
|
import Jwt, {JsonWebTokenError} from "jsonwebtoken";
|
||||||
import {SECRET_KEY, MINIMUM_DISTANCE, GROUP_RADIUS, ALLOW_ARTILLERY} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..."
|
import {
|
||||||
|
SECRET_KEY,
|
||||||
|
MINIMUM_DISTANCE,
|
||||||
|
GROUP_RADIUS,
|
||||||
|
ALLOW_ARTILLERY,
|
||||||
|
ADMIN_API_URL,
|
||||||
|
ADMIN_API_TOKEN
|
||||||
|
} from "../Enum/EnvironmentVariable"; //TODO fix import by "_Enum/..."
|
||||||
import {World} from "../Model/World";
|
import {World} from "../Model/World";
|
||||||
import {Group} from "../Model/Group";
|
import {Group} from "../Model/Group";
|
||||||
import {User} from "../Model/User";
|
import {User} from "../Model/User";
|
||||||
@ -50,7 +57,7 @@ import {ProtobufUtils} from "../Model/Websocket/ProtobufUtils";
|
|||||||
import {App, HttpRequest, TemplatedApp, WebSocket} from "uWebSockets.js"
|
import {App, HttpRequest, TemplatedApp, WebSocket} from "uWebSockets.js"
|
||||||
import {parse} from "query-string";
|
import {parse} from "query-string";
|
||||||
import {cpuTracker} from "../Services/CpuTracker";
|
import {cpuTracker} from "../Services/CpuTracker";
|
||||||
import axios from "axios";
|
import Axios from "axios";
|
||||||
|
|
||||||
function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void {
|
function emitInBatch(socket: ExSocketInterface, payload: SubMessage): void {
|
||||||
socket.batchedMessages.addPayload(payload);
|
socket.batchedMessages.addPayload(payload);
|
||||||
@ -553,14 +560,22 @@ export class IoSocketController {
|
|||||||
private handleReportMessage(client: ExSocketInterface, reportPlayerMessage: ReportPlayerMessage) {
|
private handleReportMessage(client: ExSocketInterface, reportPlayerMessage: ReportPlayerMessage) {
|
||||||
try {
|
try {
|
||||||
let reportedSocket = this.sockets.get(reportPlayerMessage.getReporteduserid());
|
let reportedSocket = this.sockets.get(reportPlayerMessage.getReporteduserid());
|
||||||
if(!reportedSocket){
|
if (!reportedSocket) {
|
||||||
throw 'reported socket user not found';
|
throw 'reported socket user not found';
|
||||||
}
|
}
|
||||||
//TODO report user on admin application
|
//TODO report user on admin application
|
||||||
axios.post('/report', {
|
console.log('ADMIN_API_URL', ADMIN_API_URL);
|
||||||
reportedUserId: reportPlayerMessage.getReporteduserid(),
|
console.log('ADMIN_API_TOKEN', ADMIN_API_TOKEN);
|
||||||
reportedUserComment: reportPlayerMessage.getReportcomment(),
|
Axios.post(`${ADMIN_API_URL}/aoi/report`, {
|
||||||
reporterUserId: client.userUuid,
|
reportedUserUuid: client.userUuid,
|
||||||
|
reportedUserComment: reportPlayerMessage.getReportcomment(),
|
||||||
|
reporterUserUuid: client.userUuid,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {"Authorization": `${ADMIN_API_TOKEN}`}
|
||||||
|
}).catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
throw err;
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('An error occurred on "handleReportMessage"');
|
console.error('An error occurred on "handleReportMessage"');
|
||||||
|
@ -3,8 +3,8 @@ const URL_ROOM_STARTED = "/Floor0/floor0.json";
|
|||||||
const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64;
|
const MINIMUM_DISTANCE = process.env.MINIMUM_DISTANCE ? Number(process.env.MINIMUM_DISTANCE) : 64;
|
||||||
const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48;
|
const GROUP_RADIUS = process.env.GROUP_RADIUS ? Number(process.env.GROUP_RADIUS) : 48;
|
||||||
const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false;
|
const ALLOW_ARTILLERY = process.env.ALLOW_ARTILLERY ? process.env.ALLOW_ARTILLERY == 'true' : false;
|
||||||
const ADMIN_API_URL = process.env.ADMIN_API_URL || null;
|
const ADMIN_API_URL = process.env.ADMIN_API_URL || 'http://admin';
|
||||||
const ADMIN_API_TOKEN = process.env.ADMIN_API_TOKEN || null;
|
const ADMIN_API_TOKEN = process.env.ADMIN_API_TOKEN || 'myapitoken';
|
||||||
const CPU_OVERHEAT_THRESHOLD = Number(process.env.CPU_OVERHEAT_THRESHOLD) || 80;
|
const CPU_OVERHEAT_THRESHOLD = Number(process.env.CPU_OVERHEAT_THRESHOLD) || 80;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
Loading…
Reference in New Issue
Block a user