fix: api returns all backers on users so check if tier exists

This commit is contained in:
Marie 2024-10-02 18:25:06 +02:00
parent 1e0d372eb5
commit 3529042cb1
No known key found for this signature in database
GPG Key ID: 7ADF6C9CD9A28555

View File

@ -62,7 +62,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const backers = await fetch(`${meta.donationUrl}/members/users.json`).then((response) => response.json()); const backers = await fetch(`${meta.donationUrl}/members/users.json`).then((response) => response.json());
// Merge both together into one array and make sure it only has Active subscriptions // Merge both together into one array and make sure it only has Active subscriptions
const allSponsors = [...backers].filter(sponsor => sponsor.isActive === true && sponsor.role === 'BACKER'); const allSponsors = [...backers].filter(sponsor => sponsor.isActive === true && sponsor.role === 'BACKER' && sponsor.tier);
// Remove possible duplicates // Remove possible duplicates
totalSponsors = [...new Map(allSponsors.map(v => [v.profile, v])).values()]; totalSponsors = [...new Map(allSponsors.map(v => [v.profile, v])).values()];