remove old minecraft legacy code that we do not use anymore

This commit is contained in:
HF 2021-07-08 20:54:39 +02:00
parent 887fb3b763
commit 7e618a5979
7 changed files with 0 additions and 165 deletions

View File

@ -23,7 +23,6 @@ import change_name from './change_name';
import change_mail from './change_mail';
// eslint-disable-next-line camelcase
import restore_password from './restore_password';
import mclink from './mclink';
import getHtml from '../../../ssr-components/RedirectionPage';
@ -134,8 +133,6 @@ export default (passport) => {
router.post('/restore_password', restore_password);
router.post('/mclink', mclink);
// while previous auth methosed work by redirect,
// local strategy is an json API
router.post('/local', async (req: Request, res: Response, next) => {

View File

@ -1,44 +0,0 @@
/*
* accept or deny minecraft link request
* @flow
*/
import type { Request, Response } from 'express';
import webSockets from '../../../socket/websockets';
export default async (req: Request, res: Response) => {
const { accepted } = req.body;
const { user } = req;
if (!user) {
res.status(401);
res.json({
errors: ['You are not authenticated.'],
});
return;
}
const { name, minecraftid } = user.regUser;
if (accepted === true) {
user.regUser.update({
mcVerified: true,
});
res.json({
accepted: true,
});
} else if (accepted === false) {
user.regUser.update({
minecraftid: null,
minecraftname: null,
mcVerified: false,
});
res.json({
accepted: false,
});
} else {
return;
}
webSockets.broadcastMinecraftLink(name, minecraftid, accepted);
};

View File

@ -13,7 +13,6 @@ import User from '../../data/models/User';
import { getIPFromRequest } from '../../utils/ip';
import me from './me';
import mctp from './mctp';
import captcha from './captcha';
import auth from './auth';
import ranking from './ranking';
@ -84,8 +83,6 @@ router.use((req, res, next) => {
next();
});
router.post('/mctp', mctp);
router.post('/startdm', startDm);
router.post('/leavechan', leaveChan);

View File

@ -1,59 +0,0 @@
/**
*
* API endpoint to request tp in minecraft
* (might be better in websocket?)
*
* @flow
*/
import type { Request, Response } from 'express';
// eslint-disable-next-line import/no-unresolved
import canvases from './canvases.json';
import webSockets from '../../socket/websockets';
const CANVAS_MAX_XY = (canvases[0].size / 2);
const CANVAS_MIN_XY = -CANVAS_MAX_XY;
export default async (req: Request, res: Response) => {
const { user } = req;
if (!user.regUser) {
res.status(401);
res.json({
success: false,
errors: ['You are not authenticated.'],
});
return;
}
const x = parseInt(req.body.x, 10);
const y = parseInt(req.body.y, 10);
if (x < CANVAS_MIN_XY
|| y < CANVAS_MIN_XY
|| x >= CANVAS_MAX_XY
|| y >= CANVAS_MAX_XY) {
res.status(400);
res.json({
success: false,
errors: ['Coordinates out of bounds.'],
});
return;
}
const { minecraftid } = user.regUser;
if (!minecraftid) {
res.status(400);
res.json({
success: false,
errors: ['You have no minecraft account linked to you.'],
});
return;
}
webSockets.broadcastMinecraftTP(minecraftid, x, y);
res.json({
success: true,
});
};

View File

@ -100,24 +100,6 @@ class APISocketServer extends WebSocketEvents {
});
}
broadcastMinecraftLink(name, minecraftid, accepted) {
const sendmsg = JSON.stringify(['linkver', minecraftid, name, accepted]);
this.wss.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) {
client.send(sendmsg);
}
});
}
broadcastMinecraftTP(minecraftid, x, y) {
const sendmsg = JSON.stringify(['mctp', minecraftid, x, y]);
this.wss.clients.forEach((client) => {
if (client.readyState === WebSocket.OPEN) {
client.send(sendmsg);
}
});
}
broadcastOnlineCounter(buffer) {
const frame = WebSocket.Sender.frame(buffer, {
readOnly: true,

View File

@ -21,9 +21,6 @@ class WebSocketEvents {
userId: number,
) {}
broadcastMinecraftLink(name: string, minecraftid: string, accepted: boolean) {
}
broadcastAddChatChannel(
userId: number,
channelId: number,
@ -40,9 +37,6 @@ class WebSocketEvents {
reloadUser(name: string) {
}
broadcastMinecraftTP(minecraftid: string, x: number, y: number) {
}
broadcastOnlineCounter(data: Buffer) {
}
}

View File

@ -122,26 +122,6 @@ class WebSockets {
);
}
/*
* broadcast minecraft linking to API
* @param name pixelplanetname
* @param minecraftid minecraftid
* @param accepted If link request got accepted
*/
broadcastMinecraftLink(
name: string,
minecraftid: string,
accepted: boolean,
) {
this.listeners.forEach(
(listener) => listener.broadcastMinecraftLink(
name,
minecraftid,
accepted,
),
);
}
/*
* reload user on websocket to get changes
*/
@ -151,18 +131,6 @@ class WebSockets {
);
}
/*
* broadcast mc tp request to API
* @param minecraftid minecraftid
* @param x x coords
* @param y y coords
*/
broadcastMinecraftTP(minecraftid, x, y) {
this.listeners.forEach(
(listener) => listener.broadcastMinecraftTP(minecraftid, x, y),
);
}
/*
* broadcast online counter
* @param online Number of users online