Self-Hosting Update (#842)

This commit is contained in:
Luke Vella 2023-09-11 15:34:55 +01:00 committed by GitHub
parent 3e616d1e41
commit 7a5f9ae474
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 945 additions and 781 deletions

View file

@ -18,8 +18,8 @@ export const getSubscriptionStatus = async (userId: string) => {
if (user?.subscription?.active === true) {
return {
active: true,
expiresAt: user.subscription.periodEnd,
};
legacy: false,
} as const;
}
const userPaymentData = await prisma.userPaymentData.findFirst({
@ -34,18 +34,14 @@ export const getSubscriptionStatus = async (userId: string) => {
},
});
if (
userPaymentData?.endDate &&
userPaymentData.endDate.getTime() > Date.now()
) {
if (userPaymentData) {
return {
active: true,
legacy: true,
expiresAt: userPaymentData.endDate,
};
} as const;
}
return {
active: false,
};
} as const;
};