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

@@ -15,6 +15,7 @@ import {
getManageSessionUrl,
} from "~/server/billing/payments";
import { db } from "~/server/db";
import { TeamService } from "~/server/service/team-service";
export const billingRouter = createTRPCRouter({
createCheckoutSession: teamAdminProcedure.mutation(async ({ ctx }) => {
@@ -47,9 +48,6 @@ export const billingRouter = createTRPCRouter({
.mutation(async ({ ctx, input }) => {
const { billingEmail } = input;
await db.team.update({
where: { id: ctx.team.id },
data: { billingEmail },
});
await TeamService.updateTeam(ctx.team.id, { billingEmail });
}),
});

View File

@@ -1,6 +1,5 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";
import { env } from "~/env";
import { createTRPCRouter, protectedProcedure } from "~/server/api/trpc";
@@ -71,6 +70,7 @@ export const invitationRouter = createTRPCRouter({
id: input.inviteId,
},
});
// No need to invalidate cache here again
return true;
}),

View File

@@ -8,7 +8,7 @@ export const limitsRouter = createTRPCRouter({
.input(
z.object({
type: z.nativeEnum(LimitReason),
}),
})
)
.query(async ({ ctx, input }) => {
switch (input.type) {
@@ -18,8 +18,6 @@ export const limitsRouter = createTRPCRouter({
return LimitService.checkDomainLimit(ctx.team.id);
case LimitReason.TEAM_MEMBER:
return LimitService.checkTeamMemberLimit(ctx.team.id);
case LimitReason.EMAIL:
return LimitService.checkEmailLimit(ctx.team.id);
default:
// exhaustive guard
throw new Error("Unsupported limit type");