Fix: Kuratoren-Berechtigungscheck für Specials vereinheitlicht

This commit is contained in:
Hördle Bot
2025-12-03 13:11:12 +01:00
parent 33f8080aa8
commit 1f34d5813e

View File

@@ -30,7 +30,9 @@ function curatorCanEditSong(context: StaffContext, song: any, assignments: { gen
if (context.role === 'admin') return true; if (context.role === 'admin') return true;
const songGenreIds = (song.genres || []).map((g: any) => g.id); const songGenreIds = (song.genres || []).map((g: any) => g.id);
const songSpecialIds = (song.specials || []).map((s: any) => s.specialId ?? s.id); // `song.specials` enthält bereits `Special`-Objekte mit einem `id`-Feld.
// Wir verwenden daher konsistent `s.id` statt eines (nicht existenten) `specialId`.
const songSpecialIds = (song.specials || []).map((s: any) => s.id);
// Songs ohne Genres/Specials sind für Kuratoren generell editierbar // Songs ohne Genres/Specials sind für Kuratoren generell editierbar
if (songGenreIds.length === 0 && songSpecialIds.length === 0) { if (songGenreIds.length === 0 && songSpecialIds.length === 0) {
@@ -47,7 +49,7 @@ function curatorCanDeleteSong(context: StaffContext, song: any, assignments: { g
if (context.role === 'admin') return true; if (context.role === 'admin') return true;
const songGenreIds = (song.genres || []).map((g: any) => g.id); const songGenreIds = (song.genres || []).map((g: any) => g.id);
const songSpecialIds = (song.specials || []).map((s: any) => s.specialId ?? s.id); const songSpecialIds = (song.specials || []).map((s: any) => s.id);
const allGenresAllowed = songGenreIds.every((id: number) => assignments.genreIds.has(id)); const allGenresAllowed = songGenreIds.every((id: number) => assignments.genreIds.has(id));
const allSpecialsAllowed = songSpecialIds.every((id: number) => assignments.specialIds.has(id)); const allSpecialsAllowed = songSpecialIds.every((id: number) => assignments.specialIds.has(id));