Fix: Gemeinsame Spiele - profileId zu steamId Resolution

Das Multi-Platform Profile System hatte den Common-Games-Endpoint
kaputt gemacht: Client sendete profileIds (UUIDs), Server erwartete
steamIds. Endpoint loest jetzt profileIds korrekt auf.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Daniel 2026-03-09 00:47:34 +01:00
parent 7a05676037
commit ecd5e96ee2
2 changed files with 23 additions and 10 deletions

View file

@ -387,21 +387,31 @@ const gameLibraryPlugin: Plugin = {
// ── GET /api/game-library/common-games?users=id1,id2,... ── // ── GET /api/game-library/common-games?users=id1,id2,... ──
app.get('/api/game-library/common-games', (req, res) => { app.get('/api/game-library/common-games', (req, res) => {
const userIds = String(req.query.users || '').split(',').filter(Boolean); const ids = String(req.query.users || '').split(',').filter(Boolean);
if (userIds.length < 2) { if (ids.length < 2) {
res.status(400).json({ error: 'Mindestens zwei Steam-IDs erforderlich (users=id1,id2).' }); res.status(400).json({ error: 'Mindestens zwei Profile erforderlich (users=id1,id2).' });
return; return;
} }
const data = loadData(ctx); const data = loadData(ctx);
// Validate all users exist // Resolve profileIds → steamIds (profiles may be UUIDs from the multi-platform system)
for (const id of userIds) { const userIds: string[] = [];
if (!data.users[id]) { for (const id of ids) {
res.status(404).json({ error: `Benutzer ${id} nicht gefunden.` }); if (data.users[id]) {
// Direct steamId (backwards compat)
userIds.push(id);
} else {
const profile = data.profiles[id];
if (profile?.steamId && data.users[profile.steamId]) {
userIds.push(profile.steamId);
} else {
console.warn(`[GameLibrary] common-games: could not resolve id=${id}, profile=${!!profile}, steamId=${profile?.steamId}`);
res.status(404).json({ error: `Benutzer ${id} nicht gefunden oder kein Steam-Konto verknuepft.` });
return; return;
} }
} }
}
// Build game sets per user: Map<appid, SteamGame> // Build game sets per user: Map<appid, SteamGame>
const userGameMaps = userIds.map(id => { const userGameMaps = userIds.map(id => {

View file

@ -390,9 +390,12 @@ export default function GameLibraryTab({ data }: { data: any }) {
if (resp.ok) { if (resp.ok) {
const d = await resp.json(); const d = await resp.json();
setCommonGames(d.games || d); setCommonGames(d.games || d);
} else {
console.error('[GameLibrary] common-games error:', resp.status, await resp.text().catch(() => ''));
setCommonGames([]);
} }
} catch { } catch (err) {
/* silent */ console.error('[GameLibrary] common-games fetch failed:', err);
} finally { } finally {
setLoading(false); setLoading(false);
} }