Files
Hariom BalharaGitHubDevin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
a0e5e03903 feat: Add async spam check and decoy booking response (#24326)
* feat: Add async spam check integration and decoy booking response

- Integrate SpamCheckService with handleNewBooking workflow
- Implement parallel spam check execution for minimal performance impact
- Add decoy booking response with localStorage-based success page
- Extract organization ID from event type for org-specific blocking
- Add comprehensive test coverage for spam detection scenarios
- Create reusable components for booking success cards
- Implement fail-open behavior to never block legitimate bookings

This builds on the spam blocker DI infrastructure from PR #24040 by
adding the actual integration into the booking flow and implementing
the decoy response mechanism to avoid revealing spam detection to
malicious actors.

Related: #24040
Co-Authored-By: [email protected] <[email protected]>

* Do checks in paralle

* Fix leaking host name in title

* Reduce expoiry time localstorage

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2025-10-14 11:36:51 +00:00

32 lines
816 B
TypeScript

"use client";
import { useRouter } from "next/navigation";
import { useEffect, useState } from "react";
import { getDecoyBooking } from "@calcom/features/bookings/lib/client/decoyBookingStore";
import type { DecoyBookingData } from "@calcom/features/bookings/lib/client/decoyBookingStore";
/**
* Hook to retrieve and manage decoy booking data from localStorage
* @param uid - The booking uid
* @returns The booking data or null if not found/expired
*/
export function useDecoyBooking(uid: string) {
const router = useRouter();
const [bookingData, setBookingData] = useState<DecoyBookingData | null>(null);
useEffect(() => {
const data = getDecoyBooking(uid);
if (!data) {
router.push("/404");
return;
}
setBookingData(data);
}, [uid, router]);
return bookingData;
}