From 9538186eee3b9ba6885f1556dd3a8420bbc08908 Mon Sep 17 00:00:00 2001 From: Abraham Date: Thu, 13 Jul 2023 07:28:54 -0700 Subject: [PATCH] fix: patreon API (#50) --- src/providers/patreon.ts | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/providers/patreon.ts b/src/providers/patreon.ts index b36ac59..810c759 100644 --- a/src/providers/patreon.ts +++ b/src/providers/patreon.ts @@ -27,7 +27,7 @@ export async function fetchPatreonSponsors(token: string): Promise !!pledge.relationships?.reward?.data) - .filter((pledge: any) => { + .filter((membership: any) => { // Filter declined users - if (pledge.attributes.declined_since) - return new Date(pledge.attributes.declined_since).getTime() - new Date().getTime() > 0 - return true + return membership.attributes.patron_status !== 'declined_patron' }) - .map((pledge: any) => ({ - pledge, + .map((membership: any) => ({ + membership, patron: sponsorshipData.included.find( - (v: any) => v.id === pledge.relationships.patron.data.id, - ), - reward: sponsorshipData.included.find( - (v: any) => v.id === pledge.relationships.reward.data.id, + (v: any) => v.id === membership.relationships.user.data.id, ), })), ) - sponsorshipApi = sponsorshipData.links.next + sponsorshipApi = sponsorshipData.links?.next } while (sponsorshipApi) const processed = sponsors.map( @@ -70,10 +64,10 @@ export async function fetchPatreonSponsors(token: string): Promise