Add localhost-only internal Discord update route
All checks were successful
Deploy GSM / deploy (push) Successful in 28s
All checks were successful
Deploy GSM / deploy (push) Successful in 28s
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user