Skip to content

Commit

Permalink
fix: missing Patreon declined users as previous sponsors (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
ycs77 authored Sep 9, 2024
1 parent a631765 commit e54fb9e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/providers/patreon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ export async function fetchPatreonSponsors(token: string): Promise<Sponsorship[]
})
sponsors.push(
...sponsorshipData.data
.filter((membership: any) => {
// Filter out "declined" and "never pledged" members
return membership.attributes.patron_status !== 'declined_patron' && membership.attributes.patron_status !== null
})
// Filter out "never pledged" members
.filter((membership: any) => membership.attributes.patron_status !== null)
.map((membership: any) => ({
membership,
patron: sponsorshipData.included.find(
Expand All @@ -64,7 +62,8 @@ export async function fetchPatreonSponsors(token: string): Promise<Sponsorship[]
linkUrl: raw.patron.attributes.url,
},
isOneTime: false, // One-time pledges not supported
monthlyDollars: raw.membership.attributes.patron_status === 'former_patron' ? -1 : Math.floor(raw.membership.attributes.currently_entitled_amount_cents / 100),
// The "former_patron" and "declined_patron" both is past sponsors
monthlyDollars: ['former_patron', 'declined_patron'].includes(raw.membership.attributes.patron_status) ? -1 : Math.floor(raw.membership.attributes.currently_entitled_amount_cents / 100),
privacyLevel: 'PUBLIC', // Patreon is all public
tierName: 'Patreon',
createdAt: raw.membership.attributes.pledge_relationship_start,
Expand Down

0 comments on commit e54fb9e

Please sign in to comment.