chore: migrate mapList to CDN tab & update replacements

This commit is contained in:
Rim
2025-04-19 22:31:14 -04:00
parent 6b53294330
commit 0b067d2645
3 changed files with 31 additions and 32 deletions

26
app.js
View File

@ -146,11 +146,6 @@ app.post('/api/stats', async (req, res) => {
return res.status(400).json({ error: 'SSO Token is required' });
} */
// For mapList, username is not required
if (apiCall !== 'mapList' && !username) {
return res.status(400).json({ error: 'Username is required' });
}
// Clear previous session if it exists
if (activeSessions.has(ssoToken)) {
logger.debug('Clearing previous session');
@ -181,7 +176,7 @@ app.post('/api/stats', async (req, res) => {
// Check if the platform is valid for the game
const requiresUno = ['mw2', 'wz2', 'mw3', 'wzm'].includes(game);
if (requiresUno && platform !== 'uno' && apiCall !== 'mapList') {
if (requiresUno && platform !== 'uno') {
logger.warn(`${game} requires Uno ID`);
return res.status(200).json({
status: 'error',
@ -296,19 +291,6 @@ app.post('/api/stats', async (req, res) => {
timestamp: global.Utils.toIsoString(new Date()),
});
}
} else if (apiCall === 'mapList') {
// Fetch map list (only valid for MW)
if (game === 'mw') {
data = await fetchWithTimeout(() =>
API.ModernWarfare.mapList(platform)
);
} else {
return res.status(200).json({
status: 'error',
message: 'Map list is only available for Modern Warfare',
timestamp: global.Utils.toIsoString(new Date()),
});
}
}
logger.debug('Data fetched successfully');
@ -871,9 +853,15 @@ app.post('/api/cdn', async (req, res) => {
try {
logger.debug(`Attempting to fetch CDN data for ${cdnCall}`);
let data;
let platform = API.platforms.Activision;
// Fetch user data based on cdnCall
switch (cdnCall) {
case 'mapList':
data = await fetchWithTimeout(() =>
API.ModernWarfare.mapList(platform)
);
break;
case 'accolades':
data = await fetchWithTimeout(() => API.CDN.accolades());
break;