Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
update reminder email and cron
Marc Seitzf5803a362ff1
diff --git a/app/api/cron/upgrade/route.ts b/app/api/cron/upgrade/route.tsindex c8111b33..54898454 100644--- a/app/api/cron/upgrade/route.ts+++ b/app/api/cron/upgrade/route.ts@@ -44,18 +44,23 @@ export async function POST(req: Request) {const results = await Promise.allSettled(users.map(async (user) => {- const { id, email, name, createdAt } = user as {id: string; email: string; name: string | null; createdAt: Date};+ const { id, email, name, createdAt } = user as {+ id: string;+ email: string;+ name: string | null;+ createdAt: Date;+ };- const userDaysLeft = calculateDaysLeft(new Date(createdAt));+ let userDaysLeft = calculateDaysLeft(new Date(createdAt));if (userDaysLeft == 5) {++ if (userDaysLeft == 3) {return await Promise.allSettled([log(- `Trial for user: *${id}* is expiring in ${userDaysLeft} days, email sent.`- ),- limiter.schedule(() =>- sendTrialEndReminderEmail(email, name)+ `Trial End Reminder for user: *${id}* is expiring in ${userDaysLeft} days, email sent.`),+ limiter.schedule(() => sendTrialEndReminderEmail(email, name)),]);}@@ -63,15 +68,22 @@ export async function POST(req: Request) {if (userDaysLeft == 1) {return await Promise.allSettled([log(- `Trial for user: *${id}* is expiring in ${userDaysLeft} days, email sent.`+ `Final Trial End Reminder for user: *${id}* is expiring in ${userDaysLeft} days, email sent.`+ ),+ limiter.schedule(() => sendTrialEndFinalReminderEmail(email, name)),+ ]);+ }++ // downgrade the user to free if user has 0 day left on trial+ if (userDaysLeft == 0) {+ return await Promise.allSettled([+ log(+ `Downgrade to free for user: *${id}* is expiring in ${userDaysLeft} days, email sent.`),prisma.user.update({- where: { id, },- data: { plan: "free", },+ where: { id },+ data: { plan: "free" },}),- limiter.schedule(() =>- sendTrialEndFinalReminderEmail(email, name)- ),]);}})diff --git a/components/emails/trial-end-final-reminder.tsx b/components/emails/trial-end-final-reminder.tsxindex 13108db2..faf4e3b4 100644--- a/components/emails/trial-end-final-reminder.tsx+++ b/components/emails/trial-end-final-reminder.tsx@@ -19,7 +19,7 @@ interface TrialEndFinalReminderEmail {}const TrialEndFinalReminderEmail = ({ name }: TrialEndFinalReminderEmail) => {- const previewText = `The document sharing infrastructure for the modern web`;+ const previewText = `Upgrade to Papermark Pro`;return (<Html>@@ -64,7 +64,7 @@ const TrialEndFinalReminderEmail = ({ name }: TrialEndFinalReminderEmail) => {pX={20}pY={12}className="bg-black rounded text-white text-xs font-semibold no-underline text-center"- href={`${process.env.NEXT_PUBLIC_BASE_URL}/settings/billing`}+ href={`https://www.papermark.io/settings/billing`}>Upgrade now</Button>diff --git a/components/emails/trial-end-reminder.tsx b/components/emails/trial-end-reminder.tsxindex f9d8a018..04018ff0 100644--- a/components/emails/trial-end-reminder.tsx+++ b/components/emails/trial-end-reminder.tsx@@ -19,7 +19,7 @@ interface TrialEndReminderEmail {}const TrialEndReminderEmail = ({ name }: TrialEndReminderEmail) => {- const previewText = `The document sharing infrastructure for the modern web`;+ const previewText = `Upgrade to Papermark Pro`;return (<Html>@@ -61,7 +61,7 @@ const TrialEndReminderEmail = ({ name }: TrialEndReminderEmail) => {pX={20}pY={12}className="bg-black rounded text-white text-xs font-semibold no-underline text-center"- href={`${process.env.NEXT_PUBLIC_BASE_URL}/settings/billing`}+ href={`https://www.papermark.io/settings/billing`}>Upgrade your plan</Button>