Skip to content

Scheduling infrastructure for absolutely everyone.

fix: opt in booking from email (#9358)

Udit Takkarc24f5200f52a
diff --git a/apps/web/pages/api/link.ts b/apps/web/pages/api/link.ts
index efae23bb338..9a0ebdba514 100644
--- a/apps/web/pages/api/link.ts
+++ b/apps/web/pages/api/link.ts
@@ -26,7 +26,7 @@ const decryptedSchema = z.object({
async function handler(req: NextApiRequest, res: NextApiResponse<Response>) {
const { action, token, reason } = querySchema.parse(req.query);
- const { bookingUid } = decryptedSchema.parse(
+ const { bookingUid, userId } = decryptedSchema.parse(
JSON.parse(symmetricDecrypt(decodeURIComponent(token), process.env.CALENDSO_ENCRYPTION_KEY || ""))
);
@@ -34,10 +34,19 @@ async function handler(req: NextApiRequest, res: NextApiResponse<Response>) {
where: { uid: bookingUid },
});
+ const user = await prisma.user.findUniqueOrThrow({
+ where: { id: userId },
+ });
+
try {
/** @see https://trpc.io/docs/server-side-calls */
const ctx = await createContext({ req, res });
- const caller = viewerRouter.createCaller({ ...ctx, req, res });
+ const caller = viewerRouter.createCaller({
+ ...ctx,
+ req,
+ res,
+ user: { ...user, locale: user?.locale ?? "en" },
+ });
await caller.bookings.confirm({
bookingId: booking.id,
recurringEventId: booking.recurringEventId || undefined,