diff --git a/apps/web/pages/api/link.ts b/apps/web/pages/api/link.ts index efae23bb33..9a0ebdba51 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) { 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) { 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,