fix: Add display_in_workshop to groupFormatter and fix filter logic
Problem: Moderation filter returned 0 groups because: 1. groupFormatter.formatGroupDetail() didn't include display_in_workshop field 2. Platform filters incorrectly required workshop consent Solution: - Add display_in_workshop and consent_timestamp to formatGroupDetail() - Remove workshop requirement from platform filters - Add default filter to show only groups with workshop consent - Fix workshop-only filter to check for consented social media Filter logic: - 'Alle Gruppen': Only groups WITH workshop consent - 'Nur Werkstatt': Groups with workshop BUT WITHOUT social media - Platform filters: Groups with that platform consent (independent of workshop)
This commit is contained in:
parent
8d2f09f71a
commit
f049c47f38
|
|
@ -53,19 +53,28 @@ router.get('/moderation/groups', async (req, res) => {
|
|||
let filteredGroups = groupsWithConsents;
|
||||
|
||||
if (workshopOnly === 'true') {
|
||||
// Filter: Nur Gruppen mit Werkstatt-Consent aber OHNE Social Media Consents
|
||||
filteredGroups = groupsWithConsents.filter(group =>
|
||||
group.display_in_workshop &&
|
||||
(!group.socialMediaConsents || group.socialMediaConsents.length === 0)
|
||||
);
|
||||
// Filter: Nur Gruppen MIT Werkstatt-Consent aber OHNE zugestimmte Social Media Consents
|
||||
filteredGroups = groupsWithConsents.filter(group => {
|
||||
// Muss Werkstatt-Consent haben
|
||||
if (!group.display_in_workshop) return false;
|
||||
|
||||
// Darf KEINE zugestimmten Social Media Consents haben
|
||||
const hasConsentedSocialMedia = group.socialMediaConsents &&
|
||||
group.socialMediaConsents.some(consent => consent.consented === 1 || consent.consented === true);
|
||||
|
||||
return !hasConsentedSocialMedia;
|
||||
});
|
||||
} else if (platform) {
|
||||
// Filter: Gruppen mit bestimmter Social Media Platform
|
||||
// Filter: Gruppen mit bestimmter Social Media Platform (unabhängig vom Werkstatt-Consent)
|
||||
filteredGroups = groupsWithConsents.filter(group =>
|
||||
group.socialMediaConsents &&
|
||||
group.socialMediaConsents.some(consent =>
|
||||
consent.platform_name === platform && consent.consented
|
||||
consent.platform_name === platform && (consent.consented === 1 || consent.consented === true)
|
||||
)
|
||||
);
|
||||
} else {
|
||||
// Kein Filter: Zeige nur Gruppen MIT Werkstatt-Consent (das ist die Mindestanforderung)
|
||||
filteredGroups = groupsWithConsents.filter(group => group.display_in_workshop);
|
||||
}
|
||||
|
||||
res.json({
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ function formatGroupDetail(groupRow, images) {
|
|||
name: groupRow.name,
|
||||
uploadDate: groupRow.upload_date,
|
||||
approved: Boolean(groupRow.approved),
|
||||
display_in_workshop: Boolean(groupRow.display_in_workshop),
|
||||
consent_timestamp: groupRow.consent_timestamp || null,
|
||||
images: images.map(img => ({
|
||||
id: img.id,
|
||||
fileName: img.file_name,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user