Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

fix(cron): limit sentEmails

Marc Seitz4f8330e00a49
diff --git a/app/api/cron/domains/route.ts b/app/api/cron/domains/route.ts
index f2a67ae0..5cc7e8aa 100644
--- a/app/api/cron/domains/route.ts
+++ b/app/api/cron/domains/route.ts
@@ -52,7 +52,7 @@ export async function POST(req: Request) {
},
},
orderBy: {
- lastChecked: "asc",
+ lastChecked: "asc", // earliest first
},
take: 100,
});
diff --git a/app/api/cron/domains/utils.ts b/app/api/cron/domains/utils.ts
index 9ce0d1a1..63b1ee78 100644
--- a/app/api/cron/domains/utils.ts
+++ b/app/api/cron/domains/utils.ts
@@ -43,6 +43,15 @@ export const handleDomainUpdates = async ({
id: true,
name: true,
sentEmails: {
+ where: {
+ type: {
+ in: [
+ "FIRST_DAY_DOMAIN_REMINDER_EMAIL",
+ "FIRST_DOMAIN_INVALID_EMAIL",
+ "SECOND_DOMAIN_INVALID_EMAIL",
+ ],
+ },
+ },
select: {
type: true,
domainSlug: true,