fix: increment iCalSequence when changing booking location#22847
fix: increment iCalSequence when changing booking location#22847
Conversation
- Add iCalSequence parameter to buildCalEventFromBooking function - Update editLocation handler to increment sequence by 1 in CalendarEvent - Update database with incremented iCalSequence when location changes - Update buildCalEventFromBooking test to include new fields - Ensures ICS files properly update existing calendar events instead of creating duplicates Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
WalkthroughThe changes introduce and propagate two new fields, Estimated code review effort🎯 3 (Moderate) | ⏱️ ~15–20 minutes
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (2)**/*.ts📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)
Files:
**/*.{ts,tsx}📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)
Files:
🧠 Learnings (8)📓 Common learnings📚 Learning: in the failedbookingsbyfield component (packages/features/insights/components/failedbookingsbyfield....Applied to files:
📚 Learning: the office365calendar webhook handler in packages/app-store/office365calendar/api/webhook.ts is spec...Applied to files:
📚 Learning: the filterhostsbysameroundrobinhost function in packages/lib/bookings/filterhostsbysameroundrobinhos...Applied to files:
📚 Learning: in the insightsbookingservice (packages/lib/server/service/insightsbooking.ts), the constructor stor...Applied to files:
📚 Learning: applies to **/*repository.ts : repository files must include `repository` suffix, prefix with techno...Applied to files:
📚 Learning: the outlook calendar integration in cal.com intentionally reuses subscription ids across multiple ev...Applied to files:
📚 Learning: in cal.com's calendar integration, both google calendar and outlook calendar are designed to allow m...Applied to files:
🧬 Code Graph Analysis (1)packages/trpc/server/routers/viewer/bookings/editLocation.handler.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (10)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
Graphite Automations"Add consumer team as reviewer" took an action on this PR • (07/31/25)1 reviewer was added to this PR based on Keith Williams's automation. |
E2E results are ready! |
fix: increment iCalSequence when changing booking location
Summary
Fixes an issue where changing a booking location doesn't increment the ICS sequence number, preventing calendar applications from properly updating existing events instead of creating duplicates.
Key Changes:
editLocation.handler.tsto increment iCalSequence by 1 when location changesbuildCalEventFromBooking.tsto accept and include iCalSequence in CalendarEvent objectsRoot Cause: The editLocation handler was updating the booking location but not incrementing the ICS sequence number, which violates the ICS specification requirement that sequence numbers must increment when event details change. This caused calendar applications to treat location changes as separate events rather than updates to existing events.
Review & Testing Checklist for Human
iCalSequencefield exists in the Booking model and database schemaRecommended Test Plan:
Diagram
%%{ init : { "theme" : "default" }}%% graph TD editLocationHandler["packages/trpc/server/routers/<br/>viewer/bookings/<br/>editLocation.handler.ts"]:::major-edit buildCalEvent["packages/lib/<br/>buildCalEventFromBooking.ts"]:::major-edit testFile["packages/lib/__tests__/<br/>buildCalEventFromBooking.test.ts"]:::minor-edit emailManager["packages/emails/<br/>email-manager.ts"]:::context generateIcs["packages/emails/lib/<br/>generateIcsString.ts"]:::context prismaSchema["packages/prisma/<br/>schema.prisma"]:::context editLocationHandler -->|"calls with<br/>incremented sequence"| buildCalEvent buildCalEvent -->|"returns CalendarEvent<br/>with iCalSequence"| editLocationHandler editLocationHandler -->|"updates database<br/>with new sequence"| prismaSchema editLocationHandler -->|"sends emails with<br/>updated CalendarEvent"| emailManager emailManager -->|"generates ICS with<br/>sequence number"| generateIcs subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Link to Devin run: https://app.devin.ai/sessions/3b85205fc9494243a3f7bdf8abb066a5
Requested by: @joeauyeung