Skip to content

Commit

Permalink
✨ Add clearMessages endpoint to ChatController and update GoofyContro…
Browse files Browse the repository at this point in the history
…ller to display banned IPs
Kan-A-Pesh committed Mar 26, 2024
1 parent fd1b9e4 commit e01f170
Showing 3 changed files with 24 additions and 1 deletion.
21 changes: 21 additions & 0 deletions backend/controllers/Chat.ts
Original file line number Diff line number Diff line change
@@ -111,6 +111,27 @@ class ChatController {
public static async getMessages(req: express.Request, res: express.Response) {
res.json(ChatController._messageHistory);
}

/**
* Clears the message history
* @server HTTP
*
* @param req The Express request object
* @param res The Express response object
* @param next The Express next function
*/
public static async clearMessages(req: express.Request, res: express.Response, next: express.NextFunction) {
try {
ChatController._messageHistory = [["SYSTEM@SERVER", "The message history has been cleared"]];
WSS.forceRefresh();

res.status(200).json({
message: "Message history cleared",
});
} catch (error) {
next(error);
}
}
}

export default ChatController;
3 changes: 2 additions & 1 deletion backend/controllers/Goofy.ts
Original file line number Diff line number Diff line change
@@ -38,7 +38,8 @@ class GoofyController {
<img src="${gifs[Math.floor(Math.random() * gifs.length)]}" alt="Goofy" style="width: 300px; height: 300px; margin-bottom: 20px;">
<h1>Goofy ahh hecker</h1>
<p>There are ${GoofyController._tracks.length} hacker(s) trying to hack the server</p>
<p><b>Here are their IPs:</b><br/>${GoofyController._tracks.join("<br/>")}</p>
<p><b>Btw here are the banned IPs:</b></p>
<p>${GoofyController._banned.join(", ")}</p>
<p>Good luck!</p>
</div>
`);
1 change: 1 addition & 0 deletions backend/index.ts
Original file line number Diff line number Diff line change
@@ -135,6 +135,7 @@ router.use(verifyAdmin);
router.get("/banip", GoofyController.getBannedIPs);
router.post("/banip", GoofyController.banIP);
router.post("/refresh", GoofyController.forceRefresh);
router.post("/clearchat", ChatController.clearMessages);

router.post("/auth/ban", AccountController.banUser);
router.post("/auth/mute", AccountController.muteUser);

0 comments on commit e01f170

Please sign in to comment.