Skip to content

Booking status base#12

Closed
malinosqui wants to merge 2 commits into
ai-code-review-evaluation:booking-status-basefrom
malinosqui:booking-status-base
Closed

Booking status base#12
malinosqui wants to merge 2 commits into
ai-code-review-evaluation:booking-status-basefrom
malinosqui:booking-status-base

Conversation

@malinosqui

@malinosqui malinosqui commented Oct 18, 2025

Copy link
Copy Markdown

What does this PR do?

  • Fixes #XXXX (GitHub issue number)
  • Fixes CAL-XXXX (Linear issue number - should be visible at the bottom of the GitHub issue description)

Visual Demo (For contributors especially)

A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).

Video Demo (if applicable):

  • Show screen recordings of the issue or feature.
  • Demonstrate how to reproduce the issue, the behavior before and after the change.

Image Demo (if applicable):

  • Add side-by-side screenshots of the original and updated change.
  • Highlight any significant change(s).

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

Summary by CodeRabbit

  • New Features

    • Added support for BOOKING_REJECTED and BOOKING_REQUESTED webhook trigger events, enabling webhooks for booking rejections and pending booking requests.
    • Enhanced webhook payloads with expanded field coverage including attendees, location, metadata, and booking status.
  • Tests

    • Reorganized and expanded webhook end-to-end tests with improved payload validation across multiple booking scenarios.
  • Localization

    • Added translations for new booking event types.

shivamklr and others added 2 commits May 30, 2023 15:35
…#8884)

* test: booking rejection

* test: check if webhook is called

* feat: BOOKING_REJECTED enum ,constant in backend

* feat: send booking rejected webhook to subscribers

* feat: add Booking rejected migration

* calendar event

* Revert "calendar event"

This reverts commit 28d45dccfdd3788f0124f9be8783161b1156cd09.

* feat: BOOKING_REQUESTED enum, constant, migration

* feat: Send BOOKING REQUESTED Webhook call

* feat: Add booking rejected/requested event in form

* feat: data-testid to rejection confirm btn

* test: BOOKING_REJECTED, BOOKING_REQUESTED

* fix: booking status PENDING, Linting

* feat: add new labels to common.json

* remove: meeting ended hook from request hook

* refactor: abstract handleWebhookTrigger

* fix: create a single file for migration

* refactor: reduce code repetition and fix test

* feat: add team webhooks to subscriberOptions

* refactor: subscriberOptions

---------

Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com>
Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
feat: Add new events to webhook BOOKING_CONFIRMED, BOOKING_REJECTED (…
@coderabbitai

coderabbitai Bot commented Oct 18, 2025

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

Walkthrough

This PR introduces support for two new webhook trigger events (BOOKING_REJECTED and BOOKING_REQUESTED) by adding them to the database schema, constants, and UI configuration. It centralizes webhook dispatching logic through a new handleWebhookTrigger utility, refactors existing booking flows to use this utility, and extends webhook support to the booking confirmation/rejection handler with comprehensive e2e test coverage.

Changes

Cohort / File(s) Summary
Database Schema & Migrations
packages/prisma/schema.prisma, packages/prisma/migrations/20230522115850_add_enum_booking_requested_booking_rejected/migration.sql
Added two new enum members (BOOKING_REQUESTED, BOOKING_REJECTED) to the PostgreSQL WebhookTriggerEvents type via schema update and migration.
Webhook Infrastructure
packages/features/webhooks/lib/sendPayload.ts, packages/features/webhooks/lib/constants.ts, packages/features/bookings/lib/handleWebhookTrigger.ts
Exported WebhookDataType for external use; added two new core webhook trigger events to WEBHOOK_TRIGGER_EVENTS_GROUPED_BY_APP; introduced centralized handleWebhookTrigger utility that retrieves webhook subscribers and dispatches payloads in parallel.
Webhook Configuration UI
packages/features/webhooks/components/WebhookForm.tsx
Enabled BOOKING_REJECTED and BOOKING_REQUESTED as selectable webhook trigger options in the form.
Booking Business Logic
packages/features/bookings/lib/handleNewBooking.ts, packages/trpc/server/routers/viewer/bookings/confirm.handler.ts
Refactored webhook dispatch in booking creation to use centralized handleWebhookTrigger; added webhook emission for booking rejections in the confirm handler via the same centralized flow.
Testing & UI
apps/web/components/booking/BookingListItem.tsx
Added data-testid attribute to rejection confirmation button for test targeting.
E2E Tests
apps/web/playwright/webhook.e2e.ts
Reorganized test structure into three describe blocks (BOOKING_CREATED, BOOKING_REJECTED, BOOKING_REQUESTED); expanded payload validations to include dynamic field redaction and broader assertion coverage for webhook events.
Localization
apps/web/public/static/locales/en/common.json
Added two new localization keys: booking_rejected and booking_requested.

Sequence Diagram(s)

sequenceDiagram
    participant Booking Handler as Booking Handler<br/>(confirm/create)
    participant handleWebhookTrigger
    participant getWebhooks
    participant sendPayload
    participant Webhook Endpoint

    rect rgb(200, 220, 255)
    Note over Booking Handler,Webhook Endpoint: Centralized Webhook Dispatch Flow
    Booking Handler->>Booking Handler: Prepare subscriberOptions<br/>(eventType, userId, trigger)
    Booking Handler->>Booking Handler: Build webhookData<br/>(calendar event, metadata)
    Booking Handler->>handleWebhookTrigger: Call with subscriberOptions,<br/>eventTrigger, webhookData
    handleWebhookTrigger->>getWebhooks: Fetch subscribers matching<br/>subscriberOptions
    getWebhooks-->>handleWebhookTrigger: Return webhooks list
    par Parallel Dispatch
        handleWebhookTrigger->>sendPayload: Dispatch to subscriber 1
        handleWebhookTrigger->>sendPayload: Dispatch to subscriber 2
        handleWebhookTrigger->>sendPayload: Dispatch to subscriber N
    and
        sendPayload->>Webhook Endpoint: POST with payload +<br/>secret, timestamp
        Webhook Endpoint-->>sendPayload: Response
        sendPayload-->>handleWebhookTrigger: Per-subscriber result
    end
    handleWebhookTrigger->>handleWebhookTrigger: Log errors (if any)
    handleWebhookTrigger-->>Booking Handler: Complete
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

The changes involve: database schema additions with migrations, a new centralized webhook abstraction layer, refactoring of existing webhook logic across multiple booking handlers, integration into the booking confirmation flow, substantial e2e test reorganization with expanded payload validation, and new UI/localization elements. While many changes follow consistent patterns, they span multiple architectural layers and require verification of webhook dispatch correctness, event type handling, and test coverage.

Poem

🐰 Webhooks now dance in harmony,
Centralized and wild and free,
Rejections, requests—events take flight,
In parallel bursts of payload delight!
The database grows, the tests all shine,
A well-built webhook system so fine!

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18815a9 and 03f530d.

📒 Files selected for processing (11)
  • apps/web/components/booking/BookingListItem.tsx (1 hunks)
  • apps/web/playwright/webhook.e2e.ts (1 hunks)
  • apps/web/public/static/locales/en/common.json (1 hunks)
  • packages/features/bookings/lib/handleNewBooking.ts (3 hunks)
  • packages/features/bookings/lib/handleWebhookTrigger.ts (1 hunks)
  • packages/features/webhooks/components/WebhookForm.tsx (1 hunks)
  • packages/features/webhooks/lib/constants.ts (1 hunks)
  • packages/features/webhooks/lib/sendPayload.ts (1 hunks)
  • packages/prisma/migrations/20230522115850_add_enum_booking_requested_booking_rejected/migration.sql (1 hunks)
  • packages/prisma/schema.prisma (1 hunks)
  • packages/trpc/server/routers/viewer/bookings/confirm.handler.ts (2 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants