mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-10-15 21:31:11 +00:00
refactor(billing): drop the sendTestTrialEmail endpoint
The scan endpoint already covers manual runs, so the one-off sender was redundant. sendTrialExpiringEmail goes back to being module private.
This commit is contained in:
@@ -28,10 +28,7 @@ import {
|
||||
STARTUP_PRODUCT_ID,
|
||||
WEBSITE_URL,
|
||||
} from "@/server/utils/stripe";
|
||||
import {
|
||||
processTrialExpirations,
|
||||
sendTrialExpiringEmail,
|
||||
} from "@/server/utils/trial-notifications";
|
||||
import { processTrialExpirations } from "@/server/utils/trial-notifications";
|
||||
import {
|
||||
adminProcedure,
|
||||
createTRPCRouter,
|
||||
@@ -447,30 +444,6 @@ export const stripeRouter = createTRPCRouter({
|
||||
return { ok: true };
|
||||
}),
|
||||
|
||||
sendTestTrialEmail: adminProcedure
|
||||
.input(z.object({ daysRemaining: z.union([z.literal(1), z.literal(3)]) }))
|
||||
.mutation(async ({ ctx, input }) => {
|
||||
assertRootAccess(ctx);
|
||||
|
||||
const owner = await findUserById(ctx.user.ownerId);
|
||||
const billingStatus = await getBillingStatus(owner.id);
|
||||
|
||||
await sendTrialExpiringEmail({
|
||||
email: ctx.user.email,
|
||||
firstName: owner.firstName,
|
||||
planName: billingStatus.plan
|
||||
? billingStatus.plan.charAt(0).toUpperCase() +
|
||||
billingStatus.plan.slice(1)
|
||||
: "Hobby",
|
||||
daysRemaining: input.daysRemaining,
|
||||
trialEndsAt:
|
||||
billingStatus.trialEndsAt ??
|
||||
new Date(Date.now() + input.daysRemaining * 24 * 60 * 60 * 1000),
|
||||
});
|
||||
|
||||
return { sentTo: ctx.user.email };
|
||||
}),
|
||||
|
||||
runTrialExpirationJob: adminProcedure.mutation(async ({ ctx }) => {
|
||||
assertRootAccess(ctx);
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ const PLAN_LABELS: Record<string, string> = {
|
||||
const daysUntil = (timestamp: number) =>
|
||||
Math.ceil((timestamp * 1000 - Date.now()) / (1000 * 60 * 60 * 24));
|
||||
|
||||
export const sendTrialExpiringEmail = async ({
|
||||
const sendTrialExpiringEmail = async ({
|
||||
email,
|
||||
firstName,
|
||||
planName,
|
||||
|
||||
Reference in New Issue
Block a user