* feat: add toggle to opt out of booking title translation in instant meetings (#25547) * feat: add toggle to opt out of booking title translation in instant meetings Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: add autoTranslateTitleEnabled to test builder Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: respect autoTranslateTitleEnabled toggle in InstantBookingCreateService Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: fetch autoTranslateTitleEnabled directly in InstantBookingCreateService Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * refactor: rename autoTranslateTitleEnabled to autoTranslateInstantMeetingTitleEnabled - Renamed field to clarify it only applies to instant meeting title translation - Moved Prisma query to EventTypeRepository.findInstantMeetingConfigById() - Removed title translation logic from update.handler.ts (flag only controls instant meeting title) - Updated all references across the codebase - Added new i18n translation keys for the renamed field Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: add autoTranslateInstantMeetingTitleEnabled to test destructuring patterns Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: use Prisma.TeamCreateInput type for metadata in test helper Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: add autoTranslateInstantMeetingTitleEnabled to mockUpdatedEventType in test Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * refactor: use generic findByIdMinimal instead of business-specific method - Add autoTranslateInstantMeetingTitleEnabled to eventTypeSelect constant - Remove findInstantMeetingConfigById from EventTypeRepository - Update InstantBookingCreateService to use findByIdMinimal Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * refactor: remove autoTranslateInstantMeetingTitleEnabled from eventTypeSelect (not needed for findByIdMinimal) Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * feat: add autoTranslateInstantMeetingTitleEnabled to event type form defaults - Rename shouldTranslateTitle to shouldAutoTranslateInstantMeetingTitle for clarity - Add autoTranslateInstantMeetingTitleEnabled to findById and findByIdForOrgAdmin selects - Add autoTranslateInstantMeetingTitleEnabled to useEventTypeForm defaultValues Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> * fix: only update autoTranslateInstantMeetingTitleEnabled when explicitly provided Fixes issue where omitting the field in update requests would overwrite the saved opt-out setting with the default value (true). Now the field is only included in the update payload when explicitly provided. Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * chore: Create standard for rate limits --------- Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
66 lines
2.2 KiB
TypeScript
66 lines
2.2 KiB
TypeScript
import type { NextApiRequest } from "next";
|
|
|
|
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
|
import { getRecurringBookingService } from "@calcom/features/bookings/di/RecurringBookingService.container";
|
|
import type { BookingResponse } from "@calcom/features/bookings/types";
|
|
import { checkRateLimitAndThrowError } from "@calcom/lib/checkRateLimitAndThrowError";
|
|
import getIP from "@calcom/lib/getIP";
|
|
import { piiHasher } from "@calcom/lib/server/PiiHasher";
|
|
import { checkCfTurnstileToken } from "@calcom/lib/server/checkCfTurnstileToken";
|
|
import { defaultResponder } from "@calcom/lib/server/defaultResponder";
|
|
|
|
// @TODO: Didn't look at the contents of this function in order to not break old booking page.
|
|
|
|
type PlatformParams = {
|
|
platformClientId?: string;
|
|
platformCancelUrl?: string;
|
|
platformBookingUrl?: string;
|
|
platformRescheduleUrl?: string;
|
|
platformBookingLocation?: string;
|
|
};
|
|
|
|
type RequestMeta = {
|
|
userId?: number;
|
|
hostname?: string;
|
|
forcedSlug?: string;
|
|
noEmail?: boolean;
|
|
} & PlatformParams;
|
|
|
|
async function handler(req: NextApiRequest & RequestMeta) {
|
|
const userIp = getIP(req);
|
|
|
|
if (process.env.NEXT_PUBLIC_CLOUDFLARE_USE_TURNSTILE_IN_BOOKER === "1") {
|
|
await checkCfTurnstileToken({
|
|
token: req.body[0]["cfToken"] as string,
|
|
remoteIp: userIp,
|
|
});
|
|
}
|
|
|
|
await checkRateLimitAndThrowError({
|
|
rateLimitingType: "core",
|
|
identifier: `createRecurringBooking:${piiHasher.hash(userIp)}`,
|
|
});
|
|
const session = await getServerSession({ req });
|
|
/* To mimic API behavior and comply with types */
|
|
|
|
const recurringBookingService = getRecurringBookingService();
|
|
const createdBookings: BookingResponse[] = await recurringBookingService.createBooking({
|
|
bookingData: req.body,
|
|
bookingMeta: {
|
|
userId: session?.user?.id || -1,
|
|
platformClientId: req.platformClientId,
|
|
platformCancelUrl: req.platformCancelUrl,
|
|
platformBookingUrl: req.platformBookingUrl,
|
|
platformRescheduleUrl: req.platformRescheduleUrl,
|
|
platformBookingLocation: req.platformBookingLocation,
|
|
noEmail: req.noEmail,
|
|
},
|
|
});
|
|
|
|
return createdBookings;
|
|
}
|
|
|
|
export const handleRecurringEventBooking = handler;
|
|
|
|
export default defaultResponder(handler);
|