Add localhost-only internal Discord update route
All checks were successful
Deploy GSM / deploy (push) Successful in 28s

This commit is contained in:
2026-01-15 14:34:06 +01:00
parent 751991143a
commit 6b4fb7aa47

View File

@@ -900,4 +900,35 @@ router.post("/discord/send-update", authenticateToken, requireRole("superadmin")
}
});
// Internal route for sending updates (localhost only, no auth)
router.post("/discord/internal-update", async (req, res) => {
const clientIp = req.ip || req.connection.remoteAddress;
if (clientIp !== '127.0.0.1' && clientIp !== '::1' && clientIp !== '::ffff:127.0.0.1') {
return res.status(403).json({ error: "Forbidden - localhost only" });
}
const { title, description, color, serverType } = req.body;
if (!title || !description) {
return res.status(400).json({ error: "Title and description required" });
}
try {
const serverIcons = {
minecraft: '⛏️', factorio: '⚙️', zomboid: '🧟', vrising: '🧛',
palworld: '🦎', terraria: '⚔️', openttd: '🚂', hytale: '🏰'
};
const embed = new EmbedBuilder()
.setTitle((serverIcons[serverType] || '📢') + ' ' + title)
.setDescription(description)
.setColor(color || 0x5865F2)
.setTimestamp();
await sendUpdateToAllGuilds(embed);
res.json({ message: "Update sent" });
} catch (err) {
res.status(500).json({ error: err.message });
}
});
export default router;