block sending emails on limits (#216)

This commit is contained in:
KM Koushik
2025-09-08 18:08:57 +10:00
committed by GitHub
parent 5b3022c27b
commit 55d8c7e998
21 changed files with 844 additions and 132 deletions

View File

@@ -2,6 +2,8 @@ import { NextRequest, NextResponse } from "next/server";
import {
renderOtpEmail,
renderTeamInviteEmail,
renderUsageWarningEmail,
renderUsageLimitReachedEmail,
} from "~/server/email-templates";
export async function GET(request: NextRequest) {
@@ -28,6 +30,28 @@ export async function GET(request: NextRequest) {
inviterName: "John Doe",
role: "admin",
});
} else if (type === "usage-warning") {
const isPaidPlan = searchParams.get("isPaidPlan") === "true";
const period = searchParams.get("period") || "daily";
html = await renderUsageWarningEmail({
teamName: "Acme Inc",
used: 8000,
limit: 10000,
period: period as "daily" | "monthly",
manageUrl: "https://app.usesend.com/settings/billing",
isPaidPlan: isPaidPlan,
});
} else if (type === "usage-limit") {
const isPaidPlan = searchParams.get("isPaidPlan") === "true";
const period = searchParams.get("period") || "daily";
html = await renderUsageLimitReachedEmail({
teamName: "Acme Inc",
limit: 10000,
period: period as "daily" | "monthly",
manageUrl: "https://app.usesend.com/settings/billing",
isPaidPlan: isPaidPlan,
});
} else {
return NextResponse.json({ error: "Invalid type" }, { status: 400 });
}