mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-25 15:56:19 -05:00
Fix patronSince field resolution
This commit is contained in:
parent
8b77605986
commit
2df3d52e95
|
|
@ -1,5 +1,5 @@
|
|||
export const PATREON_INITIAL_URL =
|
||||
"https://www.patreon.com/api/oauth2/v2/campaigns/2744004/members?include=currently_entitled_tiers,user&fields%5Buser%5D=social_connections&fields%5Btier%5D=created_at";
|
||||
"https://www.patreon.com/api/oauth2/v2/campaigns/2744004/members?include=currently_entitled_tiers,user&fields%5Buser%5D=social_connections&fields%5Bmember%5D=pledge_relationship_start";
|
||||
|
||||
// tier 1 lowest, tier 4 highest
|
||||
export const TIER_1_ID = "6959473";
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ import {
|
|||
export const patronResponseSchema = z.object({
|
||||
data: z.array(
|
||||
z.object({
|
||||
attributes: z.object({}),
|
||||
attributes: z.object({
|
||||
pledge_relationship_start: z.string().nullish(),
|
||||
}),
|
||||
id: z.string(),
|
||||
relationships: z.object({
|
||||
currently_entitled_tiers: z.object({
|
||||
|
|
@ -24,11 +26,6 @@ export const patronResponseSchema = z.object({
|
|||
UNKNOWN_TIER_ID,
|
||||
]),
|
||||
type: z.string(),
|
||||
attributes: z
|
||||
.object({
|
||||
created_at: z.string(),
|
||||
})
|
||||
.nullish(),
|
||||
}),
|
||||
),
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -95,10 +95,7 @@ function parsePatronData({
|
|||
patronsWithIds.push({
|
||||
patreonId: patron.relationships.user.data.id,
|
||||
patronSince: dateToDatabaseTimestamp(
|
||||
new Date(
|
||||
patron.relationships.currently_entitled_tiers.data[0].attributes
|
||||
?.created_at ?? Date.now(),
|
||||
),
|
||||
new Date(patron.attributes.pledge_relationship_start ?? Date.now()),
|
||||
),
|
||||
patronTier: idToTierNumber(tier),
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user